update
This commit is contained in:
950
wp-content/plugins/secure-downloads/core/admin/api-settings.php
Normal file
950
wp-content/plugins/secure-downloads/core/admin/api-settings.php
Normal file
@@ -0,0 +1,950 @@
|
||||
<?php
|
||||
/**
|
||||
* @version 1.0
|
||||
* @package General Settings API - Saving different options
|
||||
* @category Settings API
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
* @modified 2016-02-24
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
// General Settings API - Saving different options
|
||||
class OPSD_Settings_API_General extends OPSD_Settings_API {
|
||||
|
||||
|
||||
/** Override Settings API Constructor
|
||||
* During creation, system try to load values from DB, if exist.
|
||||
*
|
||||
* @param type $id - of Settings
|
||||
*/
|
||||
public function __construct( $id = '' ){
|
||||
|
||||
$options = array(
|
||||
'db_prefix_option' => '' // 'opsd_'
|
||||
, 'db_saving_type' => 'separate'
|
||||
, 'id' => 'set_gen'
|
||||
);
|
||||
|
||||
$id = empty($id) ? $options['id'] : $id;
|
||||
|
||||
parent::__construct( $id, $options ); // Define ID of Setting page and options
|
||||
|
||||
add_action( 'opsd_after_settings_content', array($this, 'enqueue_js'), 10, 3 );
|
||||
}
|
||||
|
||||
|
||||
/** Init all fields rows for settings page */
|
||||
public function init_settings_fields() {
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$default_options_values = opsd_get_default_options();
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" G e n e r a l " >
|
||||
/*
|
||||
wp_redirect:
|
||||
/wrong-hash
|
||||
/download-expired
|
||||
/ip-not-valied
|
||||
/no-such-product
|
||||
/product-not-exist
|
||||
*/
|
||||
|
||||
// Redirection Path
|
||||
$this->fields['opsd_download_url_path'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ''
|
||||
, 'group' => 'general'
|
||||
, 'placeholder' => '/file-download/'
|
||||
, 'css' => 'width:100%;'
|
||||
, 'title' => __('URL Path', 'secure-downloads')
|
||||
, 'description' => '(' . __('Optional' , 'secure-downloads') . ') ' . __('Enter URL path, that will exist in secret URL' , 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
|
||||
);
|
||||
|
||||
// Redirection Path
|
||||
$this->fields['opsd_protected_directory_name_level1'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ''
|
||||
, 'group' => 'general'
|
||||
, 'placeholder' => 'opsd_XXXXXXXXXX'
|
||||
, 'css' => 'width:100%;'
|
||||
, 'title' => __('Upload Folder', 'secure-downloads')
|
||||
, 'description' => __('Path to upload folder' , 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
|
||||
);
|
||||
|
||||
// Secret Key
|
||||
$this->fields['opsd_secret_key'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => wp_generate_password( 30, false, false )
|
||||
, 'group' => 'general'
|
||||
, 'placeholder' => wp_generate_password( 30, false, false )
|
||||
, 'css' => 'width:100%;'
|
||||
, 'title' => __('Secret Key', 'secure-downloads')
|
||||
, 'description' => __('Enter your secret key. Secure link hash will be generated from it. Please keep it secure.' , 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
|
||||
);
|
||||
|
||||
|
||||
// Default Expiration
|
||||
|
||||
$options = array(
|
||||
'+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
|
||||
);
|
||||
$this->fields['opsd_defualt_expiration'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => '+24 hours'
|
||||
//, 'value' => '/css/skins/standard.css' //This will override value loaded from DB
|
||||
, 'title' => __('Default Expiration', 'secure-downloads')
|
||||
, 'description' => __('Select default expiration time of link' , 'secure-downloads')
|
||||
, 'options' => $options
|
||||
, 'group' => 'general'
|
||||
);
|
||||
|
||||
// Default IP Lock
|
||||
$this->fields['opsd_defualt_iplock'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ''
|
||||
, 'group' => 'general'
|
||||
, 'placeholder' => '0.0.0.0'
|
||||
, 'css' => 'width:17em;'
|
||||
, 'title' => __('Default IP address loc', 'secure-downloads')
|
||||
, 'description' => __('Enter default IP address for grant access to download file only for specific IP. Or leave empty for having no lock.' , 'secure-downloads')
|
||||
. '<div class="opsd-settings-notice notice-info" style="text-align:left">'
|
||||
. '<strong>'. __('Note', '') . '!</strong> '
|
||||
. __('To specify an IP range for grant access, use configuration like', 'secure-downloads') . ' '
|
||||
. '<br/>' . __('Example', 'secure-downloads') . ' 1: <strong>195.47.89</strong>'
|
||||
. '<br/>' . __('Example', 'secure-downloads') . ' 2: <strong>195.47</strong>'
|
||||
. '<br/>' . __('Example', 'secure-downloads') . ' 3: <strong>195</strong>'
|
||||
. '</div>'
|
||||
|
||||
);
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" E r r o r U R L s " >
|
||||
|
||||
// get_opsd_option( 'opsd_url_wrong_hash' )
|
||||
// get_opsd_option( 'opsd_url_download_expired' )
|
||||
// get_opsd_option( 'opsd_url_ip_not_valied' )
|
||||
// get_opsd_option( 'opsd_url_file_not_exist' )
|
||||
// get_opsd_option( 'opsd_url_error_opening_file' )
|
||||
|
||||
$name_of_field = 'opsd_url_wrong_hash';
|
||||
$this->fields[ $name_of_field . '_prefix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<tr valign="top" class="opsd_sub_settings_grayed0 opsd_tr_set_gen_' . $name_of_field . ' ">
|
||||
<th scope="row">'
|
||||
. OPSD_Settings_API::label_static( 'set_gen_' . $name_of_field
|
||||
, array( 'title' => __( 'Wrong hash', 'secure-downloads' ), 'label_css' => '' )
|
||||
)
|
||||
. '</th>
|
||||
<td><fieldset>' . '<code style="font-size:14px;">' . site_url() . '</code>'
|
||||
);
|
||||
$this->fields[ $name_of_field ] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ( isset( $default_options_values[ $name_of_field ] ) ) ? $default_options_values[ $name_of_field ] : ''
|
||||
, 'placeholder' => '/error-download'
|
||||
, 'css' => 'width:75%'
|
||||
, 'group' => 'warning_url'
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields[ $name_of_field . '_sufix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<p class="description" style="line-height: 1.7em;margin: 0;">'
|
||||
. __( 'Type URL of page with warning about wrong hash in link', 'secure-downloads' )
|
||||
. '</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$name_of_field = 'opsd_url_download_expired';
|
||||
$this->fields[ $name_of_field . '_prefix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<tr valign="top" class="opsd_sub_settings_grayed0 opsd_tr_set_gen_' . $name_of_field . ' ">
|
||||
<th scope="row">'
|
||||
. OPSD_Settings_API::label_static( 'set_gen_' . $name_of_field
|
||||
, array( 'title' => __( 'Link Expired', 'secure-downloads' ), 'label_css' => '' )
|
||||
)
|
||||
. '</th>
|
||||
<td><fieldset>' . '<code style="font-size:14px;">' . site_url() . '</code>'
|
||||
);
|
||||
$this->fields[ $name_of_field ] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ( isset( $default_options_values[ $name_of_field ] ) ) ? $default_options_values[ $name_of_field ] : ''
|
||||
, 'placeholder' => '/download-expired'
|
||||
, 'css' => 'width:75%'
|
||||
, 'group' => 'warning_url'
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields[ $name_of_field . '_sufix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<p class="description" style="line-height: 1.7em;margin: 0;">'
|
||||
. __( 'Type URL of page with warning about expiration of download link', 'secure-downloads' )
|
||||
. '</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$name_of_field = 'opsd_url_ip_not_valied';
|
||||
$this->fields[ $name_of_field . '_prefix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<tr valign="top" class="opsd_sub_settings_grayed0 opsd_tr_set_gen_' . $name_of_field . ' ">
|
||||
<th scope="row">'
|
||||
. OPSD_Settings_API::label_static( 'set_gen_' . $name_of_field
|
||||
, array( 'title' => __( 'IP Not Valid', 'secure-downloads' ), 'label_css' => '' )
|
||||
)
|
||||
. '</th>
|
||||
<td><fieldset>' . '<code style="font-size:14px;">' . site_url() . '</code>'
|
||||
);
|
||||
$this->fields[ $name_of_field ] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ( isset( $default_options_values[ $name_of_field ] ) ) ? $default_options_values[ $name_of_field ] : ''
|
||||
, 'placeholder' => '/error-download'
|
||||
, 'css' => 'width:75%'
|
||||
, 'group' => 'warning_url'
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields[ $name_of_field . '_sufix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<p class="description" style="line-height: 1.7em;margin: 0;">'
|
||||
. __( 'Type URL of page with warning about not valid IP for downloading', 'secure-downloads' )
|
||||
. '</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$name_of_field = 'opsd_url_file_not_exist';
|
||||
$this->fields[ $name_of_field . '_prefix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<tr valign="top" class="opsd_sub_settings_grayed0 opsd_tr_set_gen_' . $name_of_field . ' ">
|
||||
<th scope="row">'
|
||||
. OPSD_Settings_API::label_static( 'set_gen_' . $name_of_field
|
||||
, array( 'title' => __( 'File not exist', 'secure-downloads' ), 'label_css' => '' )
|
||||
)
|
||||
. '</th>
|
||||
<td><fieldset>' . '<code style="font-size:14px;">' . site_url() . '</code>'
|
||||
);
|
||||
$this->fields[ $name_of_field ] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ( isset( $default_options_values[ $name_of_field ] ) ) ? $default_options_values[ $name_of_field ] : ''
|
||||
, 'placeholder' => '/error-download'
|
||||
, 'css' => 'width:75%'
|
||||
, 'group' => 'warning_url'
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields[ $name_of_field . '_sufix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<p class="description" style="line-height: 1.7em;margin: 0;">'
|
||||
. __( 'Type URL of page with warning that requested file not exist', 'secure-downloads' )
|
||||
. '</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$name_of_field = 'opsd_url_error_opening_file';
|
||||
$this->fields[ $name_of_field . '_prefix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<tr valign="top" class="opsd_sub_settings_grayed0 opsd_tr_set_gen_' . $name_of_field . ' ">
|
||||
<th scope="row">'
|
||||
. OPSD_Settings_API::label_static( 'set_gen_' . $name_of_field
|
||||
, array( 'title' => __( 'Error File Opening', 'secure-downloads' ), 'label_css' => '' )
|
||||
)
|
||||
. '</th>
|
||||
<td><fieldset>' . '<code style="font-size:14px;">' . site_url() . '</code>'
|
||||
);
|
||||
$this->fields[ $name_of_field ] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => ( isset( $default_options_values[ $name_of_field ] ) ) ? $default_options_values[ $name_of_field ] : ''
|
||||
, 'placeholder' => '/error-download'
|
||||
, 'css' => 'width:75%'
|
||||
, 'group' => 'warning_url'
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields[ $name_of_field . '_sufix' ] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'warning_url'
|
||||
, 'html' => '<p class="description" style="line-height: 1.7em;margin: 0;">'
|
||||
. __( 'Type URL of page with warning about error of file opening', 'secure-downloads' )
|
||||
. '</p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Miscellaneous " >
|
||||
|
||||
|
||||
|
||||
|
||||
// CSV Separator ////////////////////////////////////////////////////////
|
||||
$field_options = array(
|
||||
',' => ', - ' . __( 'comma', 'secure-downloads' )
|
||||
, ';' => '; - ' . __( 'semicolon', 'secure-downloads' )
|
||||
, '|' => '| - ' . __( 'vertical bar', 'secure-downloads' )
|
||||
, '^' => '^ - ' . __( 'caret', 'secure-downloads' )
|
||||
);
|
||||
$this->fields['opsd_csv_separator'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => $default_options_values['opsd_csv_separator'] //';'
|
||||
, 'title' => __('CSV field separator', 'secure-downloads')
|
||||
, 'description' => sprintf(__('Select CSV separator of data field.' ,'secure-downloads'),'<b>','</b>')
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'opsd_listing'
|
||||
);
|
||||
// Divider ///////////////////////////////////////////////////////////////
|
||||
$this->fields['hr_opsd_csv_separator_separator'] = array( 'type' => 'hr', 'group' => 'opsd_listing' );
|
||||
|
||||
|
||||
// Dates Format ////////////////////////////////////////////////////////
|
||||
$this->fields['opsd_date_format_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'html' => '<tr valign="top" class="opsd_tr_set_gen_opsd_date_format">
|
||||
<th scope="row">'.
|
||||
OPSD_Settings_API::label_static( 'set_gen_opsd_date_format'
|
||||
, array( 'title'=> __('Date Format' , 'secure-downloads'), 'label_css' => 'margin: 0.25em 0 !important;vertical-align: middle;' ) )
|
||||
.'</th>
|
||||
<td><fieldset>'
|
||||
);
|
||||
$field_options = array();
|
||||
foreach ( array( __('F j, Y'), 'Y/m/d', 'm/d/Y', 'd/m/Y' ) as $format ) {
|
||||
$field_options[ esc_attr($format) ] = array( 'title' => date_i18n( $format ) );
|
||||
}
|
||||
$field_options['custom'] = array( 'title' => __('Custom' , 'secure-downloads') . ':', 'attr' => array( 'id' => 'date_format_selection_custom' ) );
|
||||
|
||||
$this->fields['opsd_date_format_selection'] = array(
|
||||
'type' => 'radio'
|
||||
, 'default' => get_option('date_format')
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'only_field' => true
|
||||
);
|
||||
|
||||
$opsd_date_format = get_opsd_option( 'opsd_date_format');
|
||||
$this->fields['opsd_date_format'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => $default_options_values['opsd_date_format'] //get_option('date_format')
|
||||
, 'value' => htmlentities( $opsd_date_format ) // Display value of this field in specific way
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'placeholder' => get_option('date_format')
|
||||
, 'css' => 'width:10em;'
|
||||
, 'only_field' => true
|
||||
);
|
||||
|
||||
$this->fields['opsd_date_format_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'html' => ' <span class="description"><code>' . date_i18n( $opsd_date_format ) . '</code></span>'
|
||||
. '<p class="description">'
|
||||
. sprintf(__('Type your date format for emails and the item table. %sDocumentation on date formatting%s' , 'secure-downloads'),'<br/><a href="http://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">','</a>')
|
||||
. ' </p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
// Time Format
|
||||
// $this->fields = apply_filters( 'opsd_settings_opsd_time_format', $this->fields, $default_options_values );
|
||||
|
||||
// Time Format /////////////////////////////////////////////////////////////
|
||||
$this->fields['opsd_time_format_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'html' => '<tr valign="top" class="wpbc_tr_set_gen_opsd_time_format">
|
||||
<th scope="row">'.
|
||||
OPSD_Settings_API::label_static( 'set_gen_opsd_time_format'
|
||||
, array( 'title'=> __('Time Format' ,'secure-downloads'), 'label_css' => 'margin: 0.25em 0 !important;vertical-align: middle;' ) )
|
||||
.'</th>
|
||||
<td><fieldset>'
|
||||
);
|
||||
$field_options = array();
|
||||
foreach ( array( 'g:i a', 'g:i A', 'H:i' ) as $format ) {
|
||||
$field_options[ esc_attr($format) ] = array( 'title' => date_i18n( $format ) );
|
||||
}
|
||||
$field_options['custom'] = array( 'title' => __('Custom' ,'secure-downloads') . ':', 'attr' => array( 'id' => 'time_format_selection_custom' ) );
|
||||
|
||||
$this->fields['opsd_time_format_selection'] = array(
|
||||
'type' => 'radio'
|
||||
, 'default' => 'H:i'
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'only_field' => true
|
||||
);
|
||||
|
||||
$opsd_time_format = get_opsd_option( 'opsd_time_format');
|
||||
$this->fields['opsd_time_format'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => $default_options_values['opsd_time_format'] //'H:i'
|
||||
, 'value' => htmlentities( $opsd_time_format ) // Display value of this field in specific way
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'placeholder' => 'H:i'
|
||||
, 'css' => 'width:5em;'
|
||||
, 'only_field' => true
|
||||
);
|
||||
|
||||
$this->fields['opsd_time_format_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'opsd_listing'
|
||||
, 'html' => ' <span class="description"><code>' . date_i18n( $opsd_time_format ) . '</code></span>'
|
||||
. '<p class="description">'
|
||||
. sprintf(__('Type your time format for emails and the opsd table. %sDocumentation on time formatting%s' ,'secure-downloads'),'<br/><a href="http://php.net/manual/en/function.date.php" target="_blank">','</a>')
|
||||
. ' </p>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Advanced " >
|
||||
|
||||
|
||||
//Show | Hide links for Advanced JavaScript section
|
||||
$this->fields['opsd_advanced_js_loading_settings'] = array(
|
||||
'type' => 'html'
|
||||
, 'html' =>
|
||||
'<a id="opsd_show_advanced_section_link_show" class="opsd_expand_section_link" href="javascript:void(0)">+ ' . __('Show advanced settings of JavaScript loading' , 'secure-downloads') . '</a>'
|
||||
. '<a id="opsd_show_advanced_section_link_hide" class="opsd_expand_section_link" href="javascript:void(0)" style="display:none;">- ' . __('Hide advanced settings of JavaScript loading' , 'secure-downloads') . '</a>'
|
||||
, 'cols' => 2
|
||||
, 'group' => 'advanced'
|
||||
);
|
||||
/*
|
||||
$this->fields['opsd_is_not_load_bs_script_in_client'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_is_not_load_bs_script_in_client'] //'Off'
|
||||
, 'title' => __('Disable Bootstrap loading on Front-End' , 'secure-downloads')
|
||||
, 'label' => __(' If your theme or some other plugin is load the BootStrap JavaScripts, you can disable loading of this script by this plugin.' , 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_advanced_js_loading_settings opsd_sub_settings_grayed hidden_items'
|
||||
);
|
||||
*/
|
||||
$this->fields['opsd_is_not_load_bs_script_in_admin'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_is_not_load_bs_script_in_admin'] //'Off'
|
||||
, 'title' => __('Disable Bootstrap loading on Back-End' , 'secure-downloads')
|
||||
, 'label' => __(' If your theme or some other plugin is load the BootStrap JavaScripts, you can disable loading of this script by this plugin.' , 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_advanced_js_loading_settings opsd_sub_settings_grayed hidden_items'
|
||||
);
|
||||
/*
|
||||
$this->fields['hr_calendar_before_is_load_js_css_on_specific_pages'] = array( 'type' => 'hr', 'group' => 'advanced', 'tr_class' => 'opsd_advanced_js_loading_settings opsd_sub_settings_grayed hidden_items' );
|
||||
$this->fields['opsd_is_load_js_css_on_specific_pages'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_is_load_js_css_on_specific_pages'] //'Off'
|
||||
, 'title' => __('Load JS and CSS files only on specific pages' , 'secure-downloads')
|
||||
, 'label' => __('Activate loading of CSS and JavaScript files of plugin only at specific pages.' , 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_advanced_js_loading_settings opsd_sub_settings_grayed hidden_items'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
$this->fields['opsd_pages_for_load_js_css'] = array(
|
||||
'type' => 'textarea'
|
||||
, 'default' => $default_options_values['opsd_pages_for_load_js_css'] //''
|
||||
, 'placeholder' => '/opsd-form/'
|
||||
, 'title' => __('Relative URLs of pages, where to load plugin CSS and JS files' , 'secure-downloads')
|
||||
, 'description' => sprintf(__('Enter relative URLs of pages, where you have Secure Downloads elements (item forms or availability calendars). Please enter one URL per line. Example: %s' , 'secure-downloads'),'<code>/opsd-form/</code>')
|
||||
,'description_tag' => 'p'
|
||||
, 'css' => 'width:100%'
|
||||
, 'rows' => 5
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_advanced_js_loading_settings opsd_is_load_js_css_on_specific_pages opsd_sub_settings_grayed hidden_items'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
*/
|
||||
if ( opsd_is_this_demo() )
|
||||
$this->fields['opsd_pages_for_load_js_css_demo'] = array( 'group' => 'advanced', 'type' => 'html', 'html' => opsd_get_warning_text_in_demo_mode(), 'cols' => 2 , 'tr_class' => 'opsd_advanced_js_loading_settings opsd_sub_settings_grayed hidden_items' );
|
||||
|
||||
|
||||
/*
|
||||
// Show settings of powered by notice
|
||||
$this->fields['opsd_advanced_powered_by_notice_settings'] = array(
|
||||
'type' => 'html'
|
||||
, 'html' =>
|
||||
'<a id="opsd_powered_by_link_show" class="opsd_expand_section_link" href="javascript:void(0)">+ ' . __('Show settings of powered by notice' , 'secure-downloads') . '</a>'
|
||||
. '<a id="opsd_powered_by_link_hide" class="opsd_expand_section_link" href="javascript:void(0)" style="display:none;">- ' . __('Hide settings of powered by notice' , 'secure-downloads') . '</a>'
|
||||
, 'cols' => 2
|
||||
, 'group' => 'advanced'
|
||||
);
|
||||
|
||||
$this->fields['opsd_is_show_powered_by_notice'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_is_show_powered_by_notice'] //'On'
|
||||
, 'title' => __('Powered by notice' , 'secure-downloads')
|
||||
, 'label' => sprintf(__(' Turn On/Off powered by "Item Calendar" notice under the calendar.' , 'secure-downloads'),'oplugins.com')
|
||||
, 'description' => ''
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_is_show_powered_by_notice opsd_sub_settings_grayed hidden_items'
|
||||
);
|
||||
|
||||
|
||||
$this->fields['opsd_opsd_copyright_adminpanel'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_opsd_copyright_adminpanel'] //'On'
|
||||
, 'title' => __('Help and info notices' , 'secure-downloads')
|
||||
, 'label' => sprintf(__(' Turn On/Off version notice and help link to rate plugin at admin panel.' , 'secure-downloads'),'oplugins.com')
|
||||
, 'description' => ''
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => 'opsd_is_show_powered_by_notice opsd_sub_settings_grayed hidden_items'
|
||||
);
|
||||
*/
|
||||
if ( ( ! opsd_is_this_demo() ) && ( current_user_can( 'activate_plugins' ) ) ) {
|
||||
|
||||
|
||||
$this->fields['help_plugin_system_info'] = array(
|
||||
'type' => 'help'
|
||||
, 'value' => array() //opsd_get_help_rows_about_config_in_several_languges() //FixIn: 1.1.3
|
||||
, 'class' => ''
|
||||
, 'css' => 'margin:0;padding:0;border:0;'
|
||||
, 'description' => ''
|
||||
, 'cols' => 2
|
||||
, 'group' => 'advanced'
|
||||
, 'tr_class' => ''
|
||||
, 'description_tag' => 'p'
|
||||
);
|
||||
|
||||
$this->fields['help_plugin_system_info']['value'][] =
|
||||
'<div class="clear"></div><hr/><center><a class="button button" href="'
|
||||
. opsd_get_settings_url()
|
||||
. '&system_info=show#opsd_general_settings_system_info_metabox">'
|
||||
. __('Plugin System Info' , 'secure-downloads')
|
||||
. '</a></center>';
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Information " >
|
||||
if ( function_exists( 'opsd_get_dashboard_info' ) ) {
|
||||
$this->fields['opsd_information'] = array(
|
||||
'type' => 'html'
|
||||
, 'html' => opsd_get_dashboard_info()
|
||||
, 'cols' => 2
|
||||
, 'group' => 'information'
|
||||
);
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" User permissions for plugin menu pages " >
|
||||
|
||||
|
||||
$this->fields['opsd_menu_position'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => 'top'
|
||||
, 'title' => __('Plugin menu position', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'options' => array(
|
||||
'top' => __('Top', 'secure-downloads')
|
||||
, 'middle' => __('Middle', 'secure-downloads')
|
||||
, 'bottom' => __('Bottom', 'secure-downloads')
|
||||
)
|
||||
, 'group' => 'permissions'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
|
||||
$this->fields['opsd_user_role_opsd_header'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'permissions'
|
||||
, 'html' => '<tr valign="top">
|
||||
<th scope="row" colspan="2">
|
||||
<hr/><p><strong>' . wp_kses_post( __('User permissions for plugin menu pages' , 'secure-downloads') ) . ':</strong></p>
|
||||
</th>
|
||||
</tr'
|
||||
);
|
||||
|
||||
$field_options = array();
|
||||
$field_options['subscriber'] = translate_user_role('Subscriber');
|
||||
$field_options['contributor'] = translate_user_role('Contributor');
|
||||
$field_options['author'] = translate_user_role('Author');
|
||||
$field_options['editor'] = translate_user_role('Editor');
|
||||
$field_options['administrator'] = translate_user_role('Administrator');
|
||||
|
||||
$this->fields['opsd_user_role_master'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => $default_options_values['opsd_user_role_master'] //'editor'
|
||||
, 'title' => __('Secure Links', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'permissions'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
$this->fields['opsd_user_role_addnew'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => $default_options_values['opsd_user_role_addnew'] //'editor'
|
||||
, 'title' => __('Files', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'permissions'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
$this->fields['opsd_user_role_settings'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => $default_options_values['opsd_user_role_settings'] //'administrator'
|
||||
, 'title' => __('Settings', 'secure-downloads')
|
||||
, 'description' => __('Select user access level for the menu pages of plugin' , 'secure-downloads')
|
||||
, 'description_tag' => 'p'
|
||||
, 'options' => $field_options
|
||||
, 'group' => 'permissions'
|
||||
, 'is_demo_safe' => opsd_is_this_demo()
|
||||
);
|
||||
|
||||
if ( opsd_is_this_demo() )
|
||||
$this->fields['opsd_user_role_settings_demo'] = array( 'group' => 'permissions', 'type' => 'html', 'html' => opsd_get_warning_text_in_demo_mode(), 'cols' => 2 );
|
||||
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Uninstall " >
|
||||
$this->fields['opsd_is_delete_if_deactive'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => $default_options_values['opsd_is_delete_if_deactive'] //'Off'
|
||||
, 'title' => __('Delete plugin settings, when plugin deactivated' , 'secure-downloads')
|
||||
, 'label' => __('Check this box to delete plugin settings options, when you uninstal this plugin.' , 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'uninstall'
|
||||
);
|
||||
// </editor-fold>
|
||||
|
||||
|
||||
//debuge($this->fields);die;
|
||||
}
|
||||
|
||||
|
||||
/** Add Custon JavaScript - for some specific settings options
|
||||
* Need to executes after showing of entire settings page (on hook: opsd_after_settings_content).
|
||||
* After initial definition of settings, and possible definition after POST request.
|
||||
*
|
||||
* @param type $menu_slug
|
||||
*
|
||||
*/
|
||||
public function enqueue_js( $menu_slug, $active_page_tab, $active_page_subtab ) {
|
||||
|
||||
$js_script = '';
|
||||
|
||||
// Hide Legend items
|
||||
$js_script .= "
|
||||
if ( ! jQuery('#set_gen_opsd_is_show_legend').is(':checked') ) {
|
||||
jQuery('.opsd_calendar_legend_items').addClass('hidden_items');
|
||||
}
|
||||
";
|
||||
// Hide or Show Legend items on click checkbox
|
||||
$js_script .= " jQuery('#set_gen_opsd_is_show_legend').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
jQuery('.opsd_calendar_legend_items').removeClass('hidden_items');
|
||||
} else {
|
||||
jQuery('.opsd_calendar_legend_items').addClass('hidden_items');
|
||||
}
|
||||
} ); ";
|
||||
// Thank you Message or Page
|
||||
$js_script .= "
|
||||
if ( jQuery('#type_of_thank_you_message_message').is(':checked') ) {
|
||||
jQuery('.opsd_calendar_thank_you_page').addClass('hidden_items');
|
||||
}
|
||||
if ( jQuery('#type_of_thank_you_message_page').is(':checked') ) {
|
||||
jQuery('.opsd_calendar_thank_you_message').addClass('hidden_items');
|
||||
}
|
||||
";
|
||||
$js_script .= " jQuery('input[name=\"set_gen_opsd_type_of_thank_you_message\"]').on( 'change', function(){
|
||||
if ( jQuery('#type_of_thank_you_message_message').is(':checked') ) {
|
||||
jQuery('.opsd_calendar_thank_you_message').removeClass('hidden_items');
|
||||
jQuery('.opsd_calendar_thank_you_page').addClass('hidden_items');
|
||||
} else {
|
||||
jQuery('.opsd_calendar_thank_you_message').addClass('hidden_items');
|
||||
jQuery('.opsd_calendar_thank_you_page').removeClass('hidden_items');
|
||||
}
|
||||
} ); ";
|
||||
|
||||
// Default calendar view mode (Item Listing) - set active / inctive options depend from resource selection.
|
||||
$js_script .= " jQuery('#set_gen_opsd_view_days_num').on( 'focus', function(){
|
||||
if ( jQuery('#set_gen_opsd_default_opsd_resource').length > 0 ) {
|
||||
jQuery('#set_gen_opsd_default_opsd_resource').on( 'change', function() {
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(2)').prop('selected', true);
|
||||
});
|
||||
if ( jQuery('#set_gen_opsd_default_opsd_resource').val() == '' ) {
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(0)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(1)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(2)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(3)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(4)').prop('disabled', true);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(5)').prop('disabled', true);
|
||||
} else {
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(0)').prop('disabled', true);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(1)').prop('disabled', true);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(2)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(3)').prop('disabled', true);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(4)').prop('disabled', false);
|
||||
jQuery('#set_gen_opsd_view_days_num option:eq(5)').prop('disabled', false);
|
||||
}
|
||||
}
|
||||
} ); ";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Set correct value for dates format, depend from selection of radio buttons
|
||||
$opsd_date_format = get_opsd_option( 'opsd_date_format');
|
||||
// On initial Load set correct text value and correct radio button
|
||||
$js_script .= "
|
||||
// Select by default Custom value, later check all other predefined values
|
||||
jQuery( '#date_format_selection_custom' ).prop('checked', true);
|
||||
|
||||
jQuery('input[name=\"set_gen_opsd_date_format_selection\"]').each(function() {
|
||||
var radio_button_value = jQuery( this ).val()
|
||||
var encodedStr = radio_button_value.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
|
||||
return '&#'+i.charCodeAt(0)+';';
|
||||
});
|
||||
if ( encodedStr == '". $opsd_date_format ."' ) {
|
||||
jQuery( this ).prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('#set_gen_opsd_date_format').val('". $opsd_date_format ."');
|
||||
";
|
||||
// On click Radio button "Date Format", - set value in custom Text field
|
||||
$js_script .= " jQuery('input[name=\"set_gen_opsd_date_format_selection\"]').on( 'change', function(){
|
||||
if ( ( this.checked ) && ( jQuery(this).val() != 'custom' ) ){
|
||||
|
||||
jQuery('#set_gen_opsd_date_format').val( jQuery(this).val().replace(/[\u00A0-\u9999<>\&]/gim,
|
||||
function(i) {
|
||||
return '&#'+i.charCodeAt(0)+';';
|
||||
})
|
||||
);
|
||||
}
|
||||
} ); ";
|
||||
// If we edit custom "Date Format" Text field - select Custom Radio button.
|
||||
$js_script .= " jQuery('#set_gen_opsd_date_format').on( 'change', function(){
|
||||
jQuery( '#date_format_selection_custom' ).prop('checked', true);
|
||||
} ); ";
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Set correct value for Time Format, depend from selection of radio buttons
|
||||
$opsd_time_format = get_opsd_option( 'opsd_time_format');
|
||||
// Function to load on initial stage of page loading, set correct value of text and select correct radio button.
|
||||
$js_script .= "
|
||||
// Select by default Custom value, later check all other predefined values
|
||||
jQuery( '#time_format_selection_custom' ).prop('checked', true);
|
||||
|
||||
jQuery('input[name=\"set_gen_opsd_time_format_selection\"]').each(function() {
|
||||
var radio_button_value = jQuery( this ).val()
|
||||
var encodedStr = radio_button_value.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
|
||||
return '&#'+i.charCodeAt(0)+';';
|
||||
});
|
||||
if ( encodedStr == '". $opsd_time_format ."' ) {
|
||||
jQuery( this ).prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('#set_gen_opsd_time_format').val('". $opsd_time_format ."');
|
||||
";
|
||||
// On click Radio button "Time Format", - set value in custom Text field
|
||||
$js_script .= " jQuery('input[name=\"set_gen_opsd_time_format_selection\"]').on( 'change', function(){
|
||||
if ( ( this.checked ) && ( jQuery(this).val() != 'custom' ) ){
|
||||
|
||||
jQuery('#set_gen_opsd_time_format').val( jQuery(this).val().replace(/[\u00A0-\u9999<>\&]/gim,
|
||||
function(i) {
|
||||
return '&#'+i.charCodeAt(0)+';';
|
||||
})
|
||||
);
|
||||
}
|
||||
} ); ";
|
||||
// If we edit custom "Time Format" Text field - select Custom Radio button.
|
||||
$js_script .= " jQuery('#set_gen_opsd_time_format').on( 'change', function(){
|
||||
jQuery( '#time_format_selection_custom' ).prop('checked', true);
|
||||
} ); ";
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Advanced section
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Click on "Allow unlimited items per same day(s)"
|
||||
$js_script .= " jQuery('#set_gen_opsd_is_days_always_available').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
var answer = confirm('"
|
||||
. esc_js( __( 'Warning', 'secure-downloads') ) . '! '
|
||||
. esc_js( __( 'You allow unlimited number of items per same dates, its can be a reason of double items on the same date. Do you really want to do this?', 'secure-downloads') )
|
||||
. "' );
|
||||
if ( answer) {
|
||||
this.checked = true;
|
||||
jQuery('#set_gen_opsd_check_on_server_if_dates_free').prop('checked', false );
|
||||
jQuery('#set_gen_opsd_is_show_pending_days_as_available').prop('checked', false );
|
||||
jQuery('.opsd_pending_days_as_available_sub_settings').addClass('hidden_items');
|
||||
} else {
|
||||
this.checked = false;
|
||||
}
|
||||
}
|
||||
} ); ";
|
||||
// Click on "Checking to prevent double item, during submitting item"
|
||||
$js_script .= " jQuery('#set_gen_opsd_check_on_server_if_dates_free').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
var answer = confirm('"
|
||||
. esc_js( __( 'Warning', 'secure-downloads') ) . '! '
|
||||
. esc_js( __( 'This feature can impact to speed of submitting item. Do you really want to do this?', 'secure-downloads') )
|
||||
. "' );
|
||||
if ( answer) {
|
||||
this.checked = true;
|
||||
jQuery('#set_gen_opsd_is_days_always_available').prop('checked', false );
|
||||
} else {
|
||||
this.checked = false;
|
||||
}
|
||||
}
|
||||
} ); ";
|
||||
|
||||
// Click on Show Advanced JavaScript section link
|
||||
$js_script .= " jQuery('#opsd_show_advanced_section_link_show').on( 'click', function(){
|
||||
jQuery('#opsd_show_advanced_section_link_show').slideToggle(200);
|
||||
jQuery('#opsd_show_advanced_section_link_hide').animate( {opacity: 1}, 200 ).slideToggle(200);
|
||||
jQuery('.opsd_advanced_js_loading_settings').removeClass('hidden_items');
|
||||
|
||||
if ( ! jQuery('#set_gen_opsd_is_load_js_css_on_specific_pages').is(':checked') ) {
|
||||
jQuery('.opsd_is_load_js_css_on_specific_pages').addClass('hidden_items');
|
||||
}
|
||||
} ); ";
|
||||
$js_script .= " jQuery('#opsd_show_advanced_section_link_hide').on( 'click', function(){
|
||||
jQuery('#opsd_show_advanced_section_link_hide').slideToggle(200);
|
||||
jQuery('#opsd_show_advanced_section_link_show').animate( {opacity: 1}, 200 ).slideToggle(200);
|
||||
jQuery('.opsd_advanced_js_loading_settings').addClass('hidden_items');
|
||||
} ); ";
|
||||
// Click on "is_not_load_bs_script_in_client"
|
||||
$js_script .= " jQuery('#set_gen_opsd_is_not_load_bs_script_in_client, #set_gen_opsd_is_not_load_bs_script_in_admin').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
var answer = confirm('"
|
||||
. esc_js( __( 'Warning', 'secure-downloads') ) . '! '
|
||||
. esc_js( __( 'You are need to be sure what you are doing. You are disable of loading some JavaScripts Do you really want to do this?', 'secure-downloads') )
|
||||
. "' );
|
||||
if ( answer) {
|
||||
this.checked = true;
|
||||
} else {
|
||||
this.checked = false;
|
||||
}
|
||||
}
|
||||
} ); ";
|
||||
$js_script .= " jQuery('#set_gen_opsd_is_load_js_css_on_specific_pages').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
var answer = confirm('"
|
||||
. esc_js( __( 'Warning', 'secure-downloads') ) . '! '
|
||||
. esc_js( __( 'You are need to be sure what you are doing. You are disable of loading some JavaScripts Do you really want to do this?', 'secure-downloads') )
|
||||
. "' );
|
||||
if ( answer) {
|
||||
this.checked = true;
|
||||
jQuery('.opsd_is_load_js_css_on_specific_pages').removeClass('hidden_items');
|
||||
} else {
|
||||
this.checked = false;
|
||||
}
|
||||
} else {
|
||||
jQuery('.opsd_is_load_js_css_on_specific_pages').addClass('hidden_items');
|
||||
}
|
||||
} );
|
||||
";
|
||||
|
||||
|
||||
// Click on Powered by links
|
||||
$js_script .= " jQuery('#opsd_powered_by_link_show').on( 'click', function(){
|
||||
jQuery('#opsd_powered_by_link_show').slideToggle(200);
|
||||
jQuery('#opsd_powered_by_link_hide').animate( {opacity: 1}, 200 ).slideToggle(200);
|
||||
jQuery('.opsd_is_show_powered_by_notice').removeClass('hidden_items');
|
||||
} ); ";
|
||||
$js_script .= " jQuery('#opsd_powered_by_link_hide').on( 'click', function(){
|
||||
jQuery('#opsd_powered_by_link_hide').slideToggle(200);
|
||||
jQuery('#opsd_powered_by_link_show').animate( {opacity: 1}, 200 ).slideToggle(200);
|
||||
jQuery('.opsd_is_show_powered_by_notice').addClass('hidden_items');
|
||||
} ); ";
|
||||
|
||||
|
||||
// Show confirmation window, if user activate this checkbox
|
||||
$js_script .= " jQuery('#set_gen_opsd_is_delete_if_deactive').on( 'change', function(){
|
||||
if ( this.checked ) {
|
||||
var answer = confirm('"
|
||||
. esc_js( __( 'Warning', 'secure-downloads') ) . '! '
|
||||
. esc_js( __( 'If you check this option, all data will be deleted when you uninstall this plugin. Do you really want to do this?', 'secure-downloads') )
|
||||
. "' );
|
||||
if ( answer) {
|
||||
this.checked = true;
|
||||
} else {
|
||||
this.checked = false;
|
||||
}
|
||||
}
|
||||
} );
|
||||
";
|
||||
|
||||
|
||||
// Eneque JS to the footer of the page
|
||||
opsd_enqueue_js( $js_script );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Override VALIDATED fields BEFORE saving to DB
|
||||
* Description:
|
||||
* Check "Thank you page" URL
|
||||
*
|
||||
* @param array $validated_fields
|
||||
*/
|
||||
function opsd_settings_validate_fields_before_saving__all( $validated_fields ) {
|
||||
|
||||
|
||||
$validated_fields['opsd_url_wrong_hash'] = opsd_make_link_relative( $validated_fields['opsd_url_wrong_hash'] );
|
||||
$validated_fields['opsd_url_download_expired'] = opsd_make_link_relative( $validated_fields['opsd_url_download_expired'] );
|
||||
$validated_fields['opsd_url_ip_not_valied'] = opsd_make_link_relative( $validated_fields['opsd_url_ip_not_valied'] );
|
||||
$validated_fields['opsd_url_file_not_exist'] = opsd_make_link_relative( $validated_fields['opsd_url_file_not_exist'] );
|
||||
$validated_fields['opsd_url_error_opening_file'] = opsd_make_link_relative( $validated_fields['opsd_url_error_opening_file'] );
|
||||
|
||||
unset( $validated_fields[ 'opsd_date_format_selection' ] ); // We do not need to this field, because saving to DB only: "date_format" field
|
||||
unset( $validated_fields[ 'opsd_time_format_selection' ] ); // We do not need to this field, because saving to DB only: "time_format" field
|
||||
|
||||
return $validated_fields;
|
||||
}
|
||||
add_filter( 'opsd_settings_validate_fields_before_saving', 'opsd_settings_validate_fields_before_saving__all', 10, 1 ); // Hook for validated fields.
|
||||
@@ -0,0 +1,462 @@
|
||||
<?php /**
|
||||
* @version 1.1
|
||||
* @package Secure Downloads
|
||||
* @category item Listing Table in Admin Panel
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-12-28
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
class OPSD_OPSD_Listing_Table {
|
||||
|
||||
public $items;
|
||||
public $opsd_types;
|
||||
|
||||
private $url; // URL for differnt Menus
|
||||
private $user_id; // ID of logged in users
|
||||
private $is_free; // Version type
|
||||
private $days_column_style; // CSS Styles for days columns
|
||||
private $date_view_type; // Initial Days View mode
|
||||
|
||||
|
||||
public function __construct( $items, $opsd_types ) {
|
||||
|
||||
$this->items = $items;
|
||||
$this->opsd_types = $opsd_types;
|
||||
|
||||
$this->url = array();
|
||||
$this->days_column_style = array( 'wide' => 'color:#333;', 'short' => 'color:#333;' );
|
||||
$this->init_params();
|
||||
}
|
||||
|
||||
|
||||
/** Get URL for specific menu
|
||||
*
|
||||
* @param sting $url - 'master' | 'add' | 'settings' | 'request'
|
||||
* @return string - url
|
||||
*/
|
||||
public function get_url( $url = 'listing') {
|
||||
if ( isset( $this->url[ $url ] ) )
|
||||
return $this->url[ $url ];
|
||||
else
|
||||
$this->url[ 'master' ];
|
||||
}
|
||||
|
||||
|
||||
/** Check if items exist or no */
|
||||
public function is_items_exist() {
|
||||
if ( count( $this->items ) > 0 )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** Init Paramteres */
|
||||
private function init_params() {
|
||||
|
||||
$user = wp_get_current_user();
|
||||
$this->user_id = $user->ID;
|
||||
|
||||
$this->url['master'] = 'admin.php?page=' . opsd_get_master_url( false );
|
||||
$this->url['add'] = 'admin.php?page=' . opsd_get_new_opsd_url( false );
|
||||
$this->url['settings'] = 'admin.php?page=' . opsd_get_settings_url( false );
|
||||
|
||||
// Transform the REQESTS parameters (GET and POST) into URL
|
||||
$this->url['request'] = opsd_get_params_in_url( opsd_get_master_url( false ), array('page_num', 'wh_opsd_type') );
|
||||
|
||||
|
||||
$this->date_view_type = get_opsd_option( 'opsd_date_view_type');
|
||||
if ( $this->date_view_type == 'short' ) $this->days_column_style['wide'] .= 'display:none;';
|
||||
else $this->days_column_style['short'] .= 'display:none;';
|
||||
|
||||
$version = get_opsd_version();
|
||||
if ( $version == 'free' ) $this->is_free = true;
|
||||
else $this->is_free = false;
|
||||
}
|
||||
|
||||
|
||||
/** Show Listing Table */
|
||||
public function show() {
|
||||
|
||||
?><div id="listing_visible_opsd" class="container-fluid table table-striped opsd_selectable_table"><?php
|
||||
|
||||
if ( $this->is_items_exist() ) {
|
||||
|
||||
$this->header( $this->is_free );
|
||||
|
||||
?><span class="opsd_selectable_body"><?php
|
||||
|
||||
$this->rows( $this->is_free );
|
||||
|
||||
?></span><?php
|
||||
|
||||
} else {
|
||||
?><center>
|
||||
<h4><?php _e('Nothing Found', 'secure-downloads'); ?>.</h4>
|
||||
</center><?php
|
||||
}
|
||||
|
||||
?></div><?php
|
||||
}
|
||||
|
||||
|
||||
/** Show Header */
|
||||
public function header( $is_free ) {
|
||||
|
||||
?>
|
||||
<div class="row opsd-listing-header opsd_selectable_head">
|
||||
<div class="opsd-listing-collumn col-sm-<?php echo $is_free ? '2' : '3'; ?> col-xs-4">
|
||||
<div class="row">
|
||||
<div class="opsd-no-margin col-sm-1 col-xs-1 opsd_column_1 check-column" >
|
||||
<input type="checkbox" onclick="javascript:opsd_set_checkbox_in_table( this.checked, 'opsd_list_item_checkbox' );" class="opsd-no-margin" style="vertical-align: middle;"/>
|
||||
</div>
|
||||
<div class="opsd-no-margin col-sm-1 col-xs-5 text-center opsd_column_2">
|
||||
<?php _e('ID', 'secure-downloads'); ?>
|
||||
</div>
|
||||
<div class="opsd-no-margin col-sm-<?php echo $is_free ? '6' : '7'; ?> text-left hide-sm opsd_column_3">
|
||||
<?php _e('Labels' , 'secure-downloads'); if ( ! $is_free ) { echo ' / '; _e('Actions' , 'secure-downloads'); } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="opsd-listing-collumn col-sm-6 col-xs-6 text-center opsd_column_4"><?php _e('Item Data', 'secure-downloads'); ?></div>
|
||||
<div class="opsd-listing-collumn col-sm-3 hide-sm text-center opsd_column_5"><?php _e('Item Dates', 'secure-downloads'); ?>
|
||||
<a id="opsd_dates_full"
|
||||
onclick="javascript:jQuery('#opsd_dates_full,.opsd_dates_small').hide();jQuery('#opsd_dates_small,.opsd_dates_full').show();" href="javascript:void(0)"
|
||||
title="<?php _e('Show ALL dates of item' , 'secure-downloads'); ?>"
|
||||
style="<?php echo $this->days_column_style['short']; ?>"
|
||||
class="tooltip_top"
|
||||
><i class="glyphicon glyphicon-resize-full" style=" margin-top: 2px;"></i></a>
|
||||
<a id="opsd_dates_small"
|
||||
onclick="javascript:jQuery('#opsd_dates_small,.opsd_dates_full').hide();jQuery('#opsd_dates_full,.opsd_dates_small').show();" href="javascript:void(0)"
|
||||
title="<?php _e('Show only check in/out dates' , 'secure-downloads'); ?>"
|
||||
style="<?php echo $this->days_column_style['wide']; ?>"
|
||||
class="tooltip_top"
|
||||
><i class="glyphicon glyphicon-resize-small" style=" margin-top: 2px;"></i></a>
|
||||
</div>
|
||||
<?php if ( $is_free ) { ?>
|
||||
<div class="opsd-listing-collumn col-sm-1 hide-sm text-center opsd_column_6"><?php _e('Actions', 'secure-downloads'); ?></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/** Show Listing Rows
|
||||
*
|
||||
* @param boolean $is_free
|
||||
*/
|
||||
public function rows( $is_free ) {
|
||||
|
||||
$availbale_locales_in_system = get_available_languages();
|
||||
$print_data = apply_opsd_filter( 'opsd_print_get_header', array( array() ) ); // P
|
||||
$bk_key = 0;
|
||||
|
||||
//TODO: blank data
|
||||
$this->items = 'a:1:{i:121;O:8:"stdClass":19:{s:10:"booking_id";s:3:"121";s:5:"trash";s:1:"0";s:8:"sync_gid";s:0:"";s:6:"is_new";s:1:"1";s:6:"status";s:0:"";s:9:"sort_date";s:19:"2017-11-22 00:00:00";s:17:"modification_date";s:19:"2017-05-14 10:25:15";s:4:"form";s:261:"text^name4^William~text^secondname4^Wilyson~text^email4^Wilyson.example@wpbookingcalendar.com~text^address4^200 Lincoln Ave~text^city4^Glasgow~text^postcode4^92073~text^country4^UK~text^phone4^927-80-51~select-one^visitors4^1~textarea^details4^~coupon^coupon4^ ";s:4:"hash";s:32:"0020d451b4bf5a34a3e65928128d2c85";s:12:"booking_type";s:1:"4";s:6:"remark";N;s:4:"cost";s:6:"960.00";s:10:"pay_status";s:0:"";s:11:"pay_request";s:1:"0";s:5:"dates";a:5:{i:0;O:8:"stdClass":4:{s:10:"booking_id";s:3:"121";s:12:"booking_date";s:19:"2017-11-22 00:00:00";s:8:"approved";s:1:"0";s:7:"type_id";N;}i:1;O:8:"stdClass":4:{s:10:"booking_id";s:3:"121";s:12:"booking_date";s:19:"2017-11-23 00:00:00";s:8:"approved";s:1:"0";s:7:"type_id";N;}i:2;O:8:"stdClass":4:{s:10:"booking_id";s:3:"121";s:12:"booking_date";s:19:"2017-11-24 00:00:00";s:8:"approved";s:1:"0";s:7:"type_id";N;}i:3;O:8:"stdClass":4:{s:10:"booking_id";s:3:"121";s:12:"booking_date";s:19:"2017-11-25 00:00:00";s:8:"approved";s:1:"0";s:7:"type_id";N;}i:4;O:8:"stdClass":4:{s:10:"booking_id";s:3:"121";s:12:"booking_date";s:19:"2017-11-26 00:00:00";s:8:"approved";s:1:"0";s:7:"type_id";N;}}s:11:"dates_short";a:3:{i:0;s:19:"2017-11-22 00:00:00";i:1;s:1:"-";i:2;s:19:"2017-11-26 00:00:00";}s:9:"form_show";s:7:" Times:";s:9:"form_data";a:7:{s:5:"email";s:37:"Wilyson.example@wpbookingcalendar.com";s:4:"name";s:7:"William";s:10:"secondname";s:7:"Wilyson";s:8:"visitors";s:1:"1";s:6:"coupon";s:1:" ";s:5:"_all_";a:11:{s:5:"name4";s:7:"William";s:11:"secondname4";s:7:"Wilyson";s:6:"email4";s:37:"Wilyson.example@wpbookingcalendar.com";s:8:"address4";s:15:"200 Lincoln Ave";s:5:"city4";s:7:"Glasgow";s:9:"postcode4";s:5:"92073";s:8:"country4";s:2:"UK";s:6:"phone4";s:9:"927-80-51";s:9:"visitors4";s:1:"1";s:8:"details4";s:0:"";s:7:"coupon4";s:1:" ";}s:12:"_all_fields_";a:18:{s:4:"name";s:7:"William";s:10:"secondname";s:7:"Wilyson";s:5:"email";s:37:"Wilyson.example@wpbookingcalendar.com";s:7:"address";s:15:"200 Lincoln Ave";s:4:"city";s:7:"Glasgow";s:8:"postcode";s:5:"92073";s:7:"country";s:2:"UK";s:5:"phone";s:9:"927-80-51";s:8:"visitors";s:1:"1";s:7:"details";s:0:"";s:6:"coupon";s:1:" ";s:19:"booking_resource_id";s:1:"4";s:11:"resource_id";s:1:"4";s:7:"type_id";s:1:"4";s:4:"type";s:1:"4";s:8:"resource";s:1:"4";s:10:"booking_id";s:3:"121";s:14:"resource_title";O:8:"stdClass":12:{s:15:"booking_type_id";s:1:"4";s:5:"title";s:11:"Apartment#3";s:5:"users";s:1:"1";s:6:"import";N;s:4:"cost";s:2:"25";s:12:"default_form";s:8:"standard";s:9:"prioritet";s:1:"0";s:6:"parent";s:1:"0";s:8:"visitors";s:1:"1";s:2:"id";s:1:"4";s:5:"count";i:1;s:2:"ID";s:1:"4";}}}s:14:"dates_short_id";a:3:{i:0;s:0:"";i:1;s:0:"";i:2;s:0:"";}}}';
|
||||
$this->items = maybe_unserialize( $this->items );
|
||||
$this->items[]=$this->items[121];
|
||||
$this->items[]=$this->items[121];
|
||||
$this->items[]=$this->items[121];
|
||||
foreach ( $this->items as $bk ) {
|
||||
|
||||
$bk_key++;
|
||||
//TODO: blank data
|
||||
$bk->form_show = '<div class="standard-content-form">
|
||||
<strong>First Name</strong>:<span class="fieldvalue">William</span>
|
||||
<strong>Last Name</strong>:<span class="fieldvalue">Wilyson</span>
|
||||
<strong>Email</strong>:<span class="fieldvalue">Wilyson.example@test.com</span>
|
||||
<strong>Phone</strong>:<span class="fieldvalue">927-80-51</span>
|
||||
<strong>Adults</strong>:<span class="fieldvalue"> 1</span>
|
||||
<strong>Children</strong>:<span class="fieldvalue"></span>
|
||||
<strong>Details</strong>: <span class="fieldvalue"> </span>
|
||||
</div>';
|
||||
$bk->opsd_id = $bk->booking_id;
|
||||
|
||||
|
||||
$row_data = array();
|
||||
$row_data[ 'availbale_locales' ] = $availbale_locales_in_system;
|
||||
$row_data[ 'css' ] = '';
|
||||
$row_data[ 'css' ] .= $bk_key % 2 ? '' : ' row_alternative_color';
|
||||
$row_data[ 'css' ] .= ( $bk_key == ( count( $this->items ) ) ) ? ' opsd-listing-last_row' : '';
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
$date_format = get_opsd_option( 'opsd_date_format' );
|
||||
if ( empty( $date_format ) ) $date_format = 'm / d / Y, D';
|
||||
$time_format = get_opsd_option( 'opsd_time_format' );
|
||||
if ( empty( $time_format ) ) $time_format = 'h:i a';
|
||||
|
||||
$row_data['cr_date'] = date_i18n( $date_format , mysql2date( 'U', $bk->modification_date ) );
|
||||
$row_data['cr_time'] = date_i18n( $time_format , mysql2date( 'U', $bk->modification_date ) );
|
||||
$row_data['id'] = $bk->opsd_id; // 100
|
||||
$row_data['is_new'] = (isset( $bk->is_new )) ? $bk->is_new : '0';
|
||||
$row_data['modification_date'] = (isset( $bk->modification_date )) ? $bk->modification_date : ''; // 2012-02-29 16:01:58
|
||||
$row_data['form'] = $bk->form; // select-one^rangetime5^10:00 - 12:00~text^name5^Jonny~text^secondname5^Smith~email^ ....
|
||||
$row_data['form_show'] = $bk->form_show; // First Name:Jonny Last Name:Smith Email:email@server.com Country:GB ....
|
||||
$row_data['form_data'] = $bk->form_data; // Array ([name] => Jonny... [_all_] => Array ( [rangetime5] => 10:00 - 12:00 [name5] => Jonny ... ) .... )
|
||||
$row_data['dates'] = $bk->dates; // Array ( [0] => stdClass Object ( [opsd_id] => 8 [opsd_date] => 2012-04-16 10:00:01 [approved] => 0 [type_id] => )
|
||||
$row_data['dates_short'] = $bk->dates_short; // Array ( [0] => 2012-04-16 10:00:01 [1] => - [2] => 2012-04-20 12:00:02 [3] => , [4] => 2012-04-16 10:00:01 ....
|
||||
$row_data['is_approved'] = ( count( $bk->dates ) > 0 ) ? $bk->dates[0]->approved : 0;
|
||||
|
||||
//Is item in Trash.
|
||||
$row_data['is_trash'] = $bk->trash ; //FixIn: 6.1.1.10
|
||||
|
||||
// BL **************************************************************
|
||||
$row_data['dates_short_id'] = ( ( count( $bk->dates ) > 0 ) && ( isset( $bk->dates_short_id ) ) ) ? $bk->dates_short_id : array(); // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 )
|
||||
|
||||
// Get SHORT Dates showing data ////////////////////////////////////
|
||||
//$row_data['short_dates_content'] = opsd_get_short_dates_formated_to_show( $row_data['dates_short'], $row_data['is_approved'], $row_data['dates_short_id'], $this->opsd_types );
|
||||
//TODO: blank data
|
||||
$row_data['short_dates_content'] = '<div class="securedownloads_dates_small" style="color: rgb(51, 51, 51); display: block;"><a href="javascript:void(0)" class="field-securedownloads-date label ">November 22, 2017<sup class="field-securedownloads-time"></sup></a><span class="date_tire"> - </span><a href="javascript:void(0)" class="field-securedownloads-date label ">November 26, 2017<sup class="field-securedownloads-time"></sup></a></div>';
|
||||
// Get WIDE Dates showing data /////////////////////////////////////
|
||||
//$row_data['wide_dates_content'] = opsd_get_wide_dates_formated_to_show( $row_data['dates'], $row_data['is_approved'], $this->opsd_types );
|
||||
//TODO: blank data
|
||||
$row_data['wide_dates_content'] = '<div class="securedownloads_dates_full" style="color: rgb(51, 51, 51); display: block;"><a href="javascript:void(0)" class="field-securedownloads-date label approved ">September 14, 2017<sup class="field-securedownloads-time"></sup></a><span class="date_tire">, </span><a href="javascript:void(0)" class="field-securedownloads-date label approved ">September 15, 2017<sup class="field-securedownloads-time"></sup></a><span class="date_tire">, </span><a href="javascript:void(0)" class="field-securedownloads-date label approved ">September 16, 2017<sup class="field-securedownloads-time"></sup></a></div>';
|
||||
// P ***************************************************************
|
||||
$row_data['resource'] = ( isset( $bk->opsd_type ) ) ? $bk->opsd_type : '1';
|
||||
$row_data['resource_name'] = '<span class="label_resource_not_exist">' . __( 'Default', 'secure-downloads') . '</span>';
|
||||
|
||||
if ( class_exists( 'opsd_personal' ) ) {
|
||||
|
||||
if ( isset( $this->opsd_types[ $row_data['resource'] ] ) ) {
|
||||
|
||||
$row_data['resource_name'] = $this->opsd_types[$row_data['resource']]->title;
|
||||
$row_data['resource_name'] = apply_opsd_filter('opsd_check_for_active_language', $row_data['resource_name'] );
|
||||
if ( strlen( $row_data['resource_name'] ) > 19 ) {
|
||||
$row_data['resource_name'] = '<span style="cursor:pointer;" class="tooltip_top" title="' . $row_data['resource_name'] . '">'
|
||||
. substr( $row_data['resource_name'], 0, 13 )
|
||||
. ' ... ' . substr( $row_data['resource_name'], -3 )
|
||||
. '</span>';
|
||||
}
|
||||
} else
|
||||
$row_data['resource_name'] = '<span class="label_resource_not_exist">' . __( 'Resource not exist', 'secure-downloads') . '</span>';
|
||||
}
|
||||
|
||||
$row_data['hash'] = (isset( $bk->hash )) ? $bk->hash : ''; // 99c9c2bd4fd0207e4376bdbf5ee473bc
|
||||
$row_data['remark'] = (isset( $bk->remark )) ? $bk->remark : '';
|
||||
|
||||
// BS **************************************************************
|
||||
$row_data['cost'] = (isset( $bk->cost )) ? $bk->cost : ''; // 150.00
|
||||
$row_data['pay_status'] = (isset( $bk->pay_status )) ? $bk->pay_status : ''; // 30800
|
||||
$row_data['pay_request'] = (isset( $bk->pay_request )) ? $bk->pay_request : ''; // 0
|
||||
$row_data['status'] = (isset( $bk->status )) ? $bk->status : '';
|
||||
$row_data['is_paid'] = 0;
|
||||
$row_data['current_payment_status_titles'] = '';
|
||||
$row_data['pay_print_status'] = '';
|
||||
|
||||
if ( class_exists( 'opsd_biz_s' ) ) {
|
||||
|
||||
if ( opsd_is_payment_status_ok( trim( $row_data['pay_status'] ) ) ) $row_data['is_paid'] = 1;
|
||||
|
||||
$payment_status_titles = get_payment_status_titles();
|
||||
$row_data['current_payment_status_titles'] = array_search( $row_data['pay_status'], $payment_status_titles );
|
||||
if ( $row_data['current_payment_status_titles'] === false )
|
||||
$row_data['current_payment_status_titles'] = $row_data['pay_status'];
|
||||
|
||||
|
||||
if ( $row_data['is_paid'] ) {
|
||||
$row_data['pay_print_status'] = __( 'Paid OK', 'secure-downloads');
|
||||
if ( $row_data['current_payment_status_titles'] == 'Completed' )
|
||||
$row_data['pay_print_status'] = $row_data['current_payment_status_titles'];
|
||||
} else if ( ( is_numeric( $row_data['pay_status'] ) ) || ( $row_data['pay_status'] == '' ) ) {
|
||||
$row_data['pay_print_status'] = __( 'Unknown', 'secure-downloads');
|
||||
} else {
|
||||
$row_data['pay_print_status'] = $row_data['current_payment_status_titles'];
|
||||
}
|
||||
}
|
||||
|
||||
// Print data /////////////////////////////////////////////////////
|
||||
$print_data[] = apply_opsd_filter( 'opsd_print_get_row'
|
||||
, array()
|
||||
, $row_data['id']
|
||||
, $row_data['is_approved']
|
||||
, $row_data['form_show']
|
||||
, $row_data['resource_name']
|
||||
, $row_data['is_paid']
|
||||
, $row_data['pay_print_status']
|
||||
, ( $this->date_view_type == 'short' ) ? '<div class="opsd_dates_small">'
|
||||
. $row_data['short_dates_content']
|
||||
. '</div>'
|
||||
: '<div class="opsd_dates_full">'
|
||||
. $row_data['wide_dates_content']
|
||||
. '</div>'
|
||||
, $row_data['cost']
|
||||
, $row_data['resource']
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
$this->show_row( $row_data, $is_free );
|
||||
}
|
||||
|
||||
make_opsd_action( 'opsd_listing_show_change_opsd_resources', $this->opsd_types );
|
||||
|
||||
make_opsd_action( 'opsd_print_loyout', $print_data );
|
||||
}
|
||||
|
||||
|
||||
/** Show 1 Listing Row
|
||||
*
|
||||
* @param array $row_data - Array of data to show
|
||||
* @param boolean $is_free
|
||||
*/
|
||||
public function show_row( $row_data, $is_free ) {
|
||||
|
||||
// is New
|
||||
?><div id="opsd_mark_<?php echo $row_data[ 'id' ]; ?>"
|
||||
class="<?php if ( $row_data[ 'is_new'] != '1') echo ' hidden_items '; ?> opsd-listing-collumn new-label clearfix-height">
|
||||
<a href="javascript:void(0)"
|
||||
onclick="javascript:console.log( '<?php echo $row_data[ 'id' ]; ?>', 0, <?php echo $this->user_id; ?>, '<?php echo opsd_get_locale(); ?>' );"
|
||||
class="tooltip_right approve_opsd_link"
|
||||
title="<?php _e('New item' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-flash"></i></a>
|
||||
</div><?php
|
||||
|
||||
// Row start
|
||||
?><div id="opsd_row_<?php echo $row_data[ 'id' ]; ?>" class="row opsd_row clearfix-height opsd-listing-row <?php echo $row_data[ 'css' ]; ?><?php echo $is_free ? ' opsd_free' : ''; ?>"><?php
|
||||
|
||||
?><div class="opsd-listing-collumn col-sm-<?php echo $is_free ? '2' : '3'; ?> col-xs-12">
|
||||
<div class="row"><?php
|
||||
|
||||
// Checkbox
|
||||
?><div class="opsd-no-margin col-sm-1 col-xs-1 field-checkbox opsd_column_1 check-column">
|
||||
<input type="checkbox" class="opsd-no-margin opsd_list_item_checkbox opsd_list_item_checkbox"
|
||||
onclick="javascript: if (jQuery(this).attr('checked') !== undefined ) { jQuery(this).parent().parent().parent().parent().addClass('row_selected_color'); } else {jQuery(this).parent().parent().parent().parent().removeClass('row_selected_color');}"
|
||||
id="opsd_id_selected_<?php echo $row_data[ 'id' ]; ?>"
|
||||
name="opsd_appr_<?php $row_data[ 'id' ]; ?>"
|
||||
/>
|
||||
</div><?php
|
||||
|
||||
// ID
|
||||
?><div class="opsd-no-margin col-sm-1 col-xs-1 field-id text-center opsd_column_2">
|
||||
<span class="label"><?php echo $row_data[ 'id' ]; ?></span>
|
||||
</div><?php
|
||||
|
||||
// Labels
|
||||
?><div class="opsd-no-margin col-sm-<?php echo $is_free ? '6' : '7'; ?> col-xs-10 text-left field-labels opsd-labels opsd_column_3" >
|
||||
<?php make_opsd_action('opsd_listing_show_label_resource', $row_data['resource_name'], $this->url['request'] .'&wh_opsd_type='. $row_data['resource'] ); ?>
|
||||
<span class="label label-default label-pending <?php if ($row_data['is_approved']) echo ' hidden_items '; ?> "><?php _e('Pending' , 'secure-downloads'); ?></span>
|
||||
<span class="label label-default label-approved <?php if (! $row_data['is_approved']) echo ' hidden_items '; ?>"><?php _e('Approved' , 'secure-downloads'); ?></span>
|
||||
<?php make_opsd_action('opsd_listing_show_payment_label', $row_data['is_paid'], $row_data['pay_print_status'], $row_data['current_payment_status_titles']); ?>
|
||||
<span class="label label-trash label-danger <?php if (! $row_data['is_trash']) echo ' hidden_items '; ?> "><?php _e('Trash' , 'secure-downloads'); ?></span><?php //FixIn: 6.1.1.10 ?>
|
||||
</div><?php
|
||||
?></div>
|
||||
</div><?php
|
||||
|
||||
// Data
|
||||
?><div class="opsd-listing-collumn col-sm-6 col-xs-12 opsd-text-justify field-content opsd_column_4">
|
||||
<?php echo $row_data['form_show']; ?>
|
||||
</div><?php
|
||||
|
||||
//Dates
|
||||
?><div class="opsd-listing-collumn col-sm-3 col-xs-12 text-center field-dates opsd-dates opsd_column_5">
|
||||
<div class="opsd_dates_small" style="<?php echo $this->days_column_style['short']; ?>"><?php echo $row_data['short_dates_content']; ?></div>
|
||||
<div class="opsd_dates_full" style="<?php echo $this->days_column_style['wide']; ?>"><?php echo $row_data['wide_dates_content']; ?></div>
|
||||
</div><?php
|
||||
|
||||
if ( ! $is_free ) {
|
||||
?><div class="clear"></div><?php
|
||||
}
|
||||
|
||||
// Actions
|
||||
?><div class="opsd-listing-collumn col-sm-<?php echo $is_free ? '1' : '10'; ?> col-xs-12 text-left field-action-buttons opsd-actions opsd_column_6"><?php
|
||||
|
||||
// Cost
|
||||
make_opsd_action( 'opsd_listing_button_cost_edit', $row_data );
|
||||
|
||||
|
||||
?><div class="actions-fields-group control-group"><?php
|
||||
|
||||
// Payment Status
|
||||
make_opsd_action('opsd_listing_button_payment_status', $row_data );
|
||||
|
||||
?><span class="opsd-buttons-separator"></span><?php
|
||||
|
||||
// Edit
|
||||
$row_data['edit_opsd_url'] = $this->url['add'] . '&opsd_type=' . $row_data['resource'] . '&opsd_hash=' . $row_data['hash'] . '&parent_res=1' ;
|
||||
make_opsd_action( 'opsd_listing_button_edit', $row_data );
|
||||
|
||||
// Change item resource
|
||||
make_opsd_action( 'opsd_listing_button_change_resource', $row_data );
|
||||
|
||||
// Duplicate
|
||||
make_opsd_action( 'opsd_listing_button_duplicate', $row_data );
|
||||
|
||||
// Print
|
||||
make_opsd_action( 'opsd_listing_button_print', $row_data );
|
||||
|
||||
// Notes
|
||||
make_opsd_action( 'opsd_listing_button_notes', $row_data );
|
||||
|
||||
// Change Locale
|
||||
make_opsd_action( 'opsd_listing_button_locale', $row_data );
|
||||
|
||||
|
||||
?><span class="opsd-buttons-separator"></span><?php
|
||||
|
||||
//FixIn: 6.1.1.10
|
||||
// Trash
|
||||
?><a href="javascript:void(0)"
|
||||
onclick="javascript:if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to do this ?' , 'secure-downloads')); ?>') ) console.log( 1, <?php echo $row_data[ 'id' ]; ?>, <?php echo $this->user_id; ?>, '<?php echo opsd_get_locale(); ?>' , 1 );"
|
||||
class="tooltip_top button-secondary button trash_opsd_link <?php if ( $row_data['is_trash'] ) echo ' hidden_items '; ?>"
|
||||
title="<?php _e('Move to trash' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-trash"></i></a><?php
|
||||
// Restore
|
||||
?><a href="javascript:void(0)"
|
||||
onclick="javascript:if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to do this ?' , 'secure-downloads')); ?>') ) console.log( 0, <?php echo $row_data[ 'id' ]; ?>, <?php echo $this->user_id; ?>, '<?php echo opsd_get_locale(); ?>' , 1 );"
|
||||
class="tooltip_top button-secondary button restore_opsd_link <?php if ( ! $row_data['is_trash'] ) echo ' hidden_items '; ?>"
|
||||
title="<?php _e('Restore' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-repeat"></i></a><?php
|
||||
// Delete
|
||||
?><a href="javascript:void(0)"
|
||||
onclick="javascript:if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to delete this item ?' , 'secure-downloads')); ?>') ) console.log(<?php echo $row_data[ 'id' ]; ?>, <?php echo $this->user_id; ?>, '<?php echo opsd_get_locale(); ?>' , 1 );"
|
||||
class="tooltip_top button-secondary button delete_opsd_link <?php if ( ! $row_data['is_trash'] ) echo ' hidden_items '; ?>"
|
||||
title="<?php _e('Completely Delete' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-remove"></i></a><?php
|
||||
//End FixIn: 6.1.1.10
|
||||
|
||||
|
||||
// Approve
|
||||
?><a href="javascript:void(0)"
|
||||
onclick="javascript:console.log(<?php echo $row_data[ 'id' ]; ?>,1,<?php echo $this->user_id; ?>,'<?php echo opsd_get_locale(); ?>',1);"
|
||||
class="tooltip_top approve_opsd_link button-secondary button <?php if ($row_data['is_approved']) echo ' hidden_items '; ?> "
|
||||
title="<?php _e('Approve' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-ok-circle"></i></a><?php
|
||||
|
||||
// Reject
|
||||
?><a href="javascript:void(0)"
|
||||
onclick="javascript:if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to set item as pending ?' , 'secure-downloads')); ?>') ) console.log(<?php echo $row_data[ 'id' ]; ?>,0, <?php echo $this->user_id; ?>, '<?php echo opsd_get_locale(); ?>' , 1 );"
|
||||
class="tooltip_top pending_opsd_link button-secondary button <?php if (! $row_data['is_approved']) echo ' hidden_items '; ?> "
|
||||
title="<?php _e('Reject' , 'secure-downloads'); ?>"
|
||||
><i class="glyphicon glyphicon-ban-circle"></i></a><?php
|
||||
|
||||
?></div><?php
|
||||
|
||||
?></div><?php
|
||||
|
||||
// Created Date
|
||||
?><div class="opsd-listing-collumn col-sm-<?php echo $is_free ? '12' : '2'; ?> col-xs-12 text-left field-system-info opsd_column_7"><?php
|
||||
?><span><?php _e('Created' , 'secure-downloads'); ?>:</span> <span class="field-creation-date"><?php echo $row_data['cr_date'], ' ', $row_data['cr_time']; ?></span><?php
|
||||
?></div><?php
|
||||
|
||||
|
||||
// Notes Section
|
||||
make_opsd_action( 'opsd_listing_section_notes', $row_data );
|
||||
|
||||
// Change Resources section
|
||||
make_opsd_action( 'opsd_listing_section_change_resource', $row_data );
|
||||
|
||||
// Payment Status Section
|
||||
make_opsd_action( 'opsd_listing_section_payment_status', $row_data );
|
||||
|
||||
|
||||
?></div><?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of Settings page
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-11-02
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
|
||||
class OPSD_Page_SettingsFields extends OPSD_Page_Structure {
|
||||
|
||||
public function in_page() {
|
||||
return 'opsd-settings';
|
||||
}
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
$tabs[ 'sub-toolbar' ] = array(
|
||||
'title' => 'Sub Toolbar Elements' // Title of TAB
|
||||
, 'hint' => 'Customizaton of Form Fields' // Hint
|
||||
, 'page_title' => 'Form fields' // 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-edit' // CSS definition of forn Icon
|
||||
, 'default' => false // Is this tab activated by default or not: true || false.
|
||||
, 'subtabs' => array()
|
||||
|
||||
);
|
||||
// $tabs[ 'upgrade' ] = array(
|
||||
// 'title' => 'Upgrade' // Title of TAB
|
||||
// , 'hint' => 'Upgrade to higher version' // Hint
|
||||
// //, 'page_title' => 'Upgrade' // Title of Page
|
||||
// , 'link' => 'http://server.com/' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
|
||||
// , 'position' => 'right' // 'left' || 'right' || ''
|
||||
// //, 'css_classes' => '' // CSS class(es)
|
||||
// //, 'icon' => '' // Icon - link to the real PNG img
|
||||
// , 'font_icon' => 'glyphicon glyphicon-shopping-cart'// CSS definition of forn Icon
|
||||
// //, 'default' => false // Is this tab activated by default or not: true || false.
|
||||
// //, 'subtabs' => array()
|
||||
//
|
||||
// );
|
||||
|
||||
$subtabs = array();
|
||||
|
||||
$subtabs['form-html-section-1'] = array( 'type' => 'html' , 'html' => '<div style="float:left;">' );
|
||||
|
||||
$subtabs['sub-toolbar'] = array(
|
||||
'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link'
|
||||
, 'title' => 'Form' // Title of TAB
|
||||
, 'page_title' => 'Form Settings' // Title of Page
|
||||
, 'hint' => 'Customization of Form Settings' // Hint
|
||||
, 'link' => '' // link
|
||||
, 'position' => '' // 'left' || 'right' || ''
|
||||
, 'css_classes' => '' // CSS class(es)
|
||||
//, 'icon' => 'https://www.paypalobjects.com/webstatic/icon/pp258.png' // Icon - link to the real PNG img
|
||||
//, 'font_icon' => 'glyphicon glyphicon-credit-card' // CSS definition of Font Icon
|
||||
, 'default' => true // Is this sub tab activated by default or not: true || false.
|
||||
, 'disabled' => false // Is this sub tab deactivated: true || false.
|
||||
, 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' )
|
||||
, 'content' => 'content' // Function to load as conten of this TAB
|
||||
);
|
||||
|
||||
$subtabs['form-separator'] = array(
|
||||
'type' => 'separator' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link'
|
||||
);
|
||||
$subtabs['form-goto'] = array(
|
||||
'type' => 'goto-link' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link'
|
||||
, 'title' =>ucwords( 'Form fields' ) // Title of TAB
|
||||
, 'hint' => '' // Hint
|
||||
, 'show_section' => 'id_of_show_section' // ID of HTML element, for scroll to.
|
||||
);
|
||||
|
||||
$subtabs['form-html-section-2'] = array( 'type' => 'html' , 'html' => '</div>' );
|
||||
|
||||
ob_start();
|
||||
$params = array(
|
||||
'label_for' => 'deny_reason1' // "For" parameter of label element
|
||||
//, 'label' => 'Reason:' // Label above the input group
|
||||
, 'style' => '' // CSS Style of entire div element
|
||||
, 'items' => array(
|
||||
array(
|
||||
'type' => 'addon'
|
||||
, 'element' => 'radio' // text | radio | checkbox
|
||||
, 'text' => 'Reason of cancelation' // Simple plain text showing
|
||||
, 'id' => 'radios' // ID, if this radio | checkbox element
|
||||
, 'name' => 'radioss' // Name, if this radio | checkbox element
|
||||
, 'value' => '' // value, if this radio | checkbox element
|
||||
, 'selected' => false // Selected, if this radio | checkbox element
|
||||
, 'legend' => '' // aria-label parameter , if this radio | checkbox element
|
||||
, 'class' => '' // Any CSS class here
|
||||
, 'attr' => array() // Any additional attributes, if this radio | checkbox element
|
||||
)
|
||||
, array(
|
||||
'type' => 'text'
|
||||
, 'id' => 'deny_reason' // HTML ID of element
|
||||
, 'value' => '' // Value of Text field
|
||||
, 'placeholder' => 'Reason of Cancelation'
|
||||
, 'style' => '' // CSS of select element
|
||||
, 'class' => '' // CSS Class of select element
|
||||
, 'attr' => array() // Any additional attributes, if this radio | checkbox element
|
||||
|
||||
)
|
||||
, array(
|
||||
'type' => 'button'
|
||||
, 'title' => 'Delete'
|
||||
, 'class' => 'button-secondary'
|
||||
, 'font_icon' => 'glyphicon glyphicon-trash'
|
||||
, 'icon_position' => 'right'
|
||||
, 'action' => "jQuery('#opsd_filters_formID').trigger( 'submit' );" )
|
||||
)
|
||||
);
|
||||
?><span style="float:left;margin:0 5px;"><div class="control-group opsd-no-padding"><?php // col-sm-2 col-xs-12 " ><?php
|
||||
opsd_bs_input_group( $params );
|
||||
?></div></span><?php
|
||||
|
||||
$html_element_data = ob_get_clean();
|
||||
|
||||
$subtabs['form-selection'] = array(
|
||||
'type' => 'html' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link'
|
||||
, 'html' => $html_element_data
|
||||
);
|
||||
/**/
|
||||
$subtabs['form-save'] = array(
|
||||
'type' => 'button' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link'
|
||||
, 'title' => 'Save Changes' // Title of TAB
|
||||
, 'form' => 'opsd_form' // Required for 'button'! Name of Form to submit
|
||||
);
|
||||
|
||||
$tabs[ 'sub-toolbar' ][ 'subtabs' ] = $subtabs;
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
|
||||
public function content() {
|
||||
debuge( 'Content <strong>' . basename(__FILE__ ) . '</strong> <span style="font-size:9px;">' . __FILE__ . '</span>');
|
||||
|
||||
|
||||
|
||||
opsd_bs_toolbar_sub_html_container_start();
|
||||
$params = array(
|
||||
'label_for' => 'deny_reason1' // "For" parameter of label element
|
||||
, 'label' => 'Reason:' // Label above the input group
|
||||
, 'style' => '' // CSS Style of entire div element
|
||||
, 'items' => array(
|
||||
array(
|
||||
'type' => 'addon'
|
||||
, 'element' => 'radio' // text | radio | checkbox
|
||||
, 'text' => 'Reason of cancelation' // Simple plain text showing
|
||||
, 'id' => 'radios' // ID, if this radio | checkbox element
|
||||
, 'name' => 'radioss' // Name, if this radio | checkbox element
|
||||
, 'value' => '' // value, if this radio | checkbox element
|
||||
, 'selected' => false // Selected, if this radio | checkbox element
|
||||
, 'legend' => '' // aria-label parameter , if this radio | checkbox element
|
||||
, 'class' => '' // Any CSS class here
|
||||
, 'attr' => array() // Any additional attributes, if this radio | checkbox element
|
||||
)
|
||||
, array(
|
||||
'type' => 'text'
|
||||
, 'id' => 'deny_reason' // HTML ID of element
|
||||
, 'value' => '' // Value of Text field
|
||||
, 'placeholder' => 'Reason of Cancelation'
|
||||
, 'style' => '' // CSS of select element
|
||||
, 'class' => '' // CSS Class of select element
|
||||
, 'attr' => array() // Any additional attributes, if this radio | checkbox element
|
||||
|
||||
)
|
||||
, array(
|
||||
'type' => 'button'
|
||||
, 'title' => 'Delete'
|
||||
, 'class' => 'button-secondary'
|
||||
, 'font_icon' => 'glyphicon glyphicon-trash'
|
||||
, 'icon_position' => 'right'
|
||||
, 'action' => "jQuery('#opsd_filters_formID').trigger( 'submit' );" )
|
||||
)
|
||||
);
|
||||
?><span class="wpdevelop"><div class="control-group opsd-no-padding"><?php // col-sm-2 col-xs-12 " ><?php
|
||||
opsd_bs_input_group( $params );
|
||||
?></div></span><?php
|
||||
opsd_bs_toolbar_sub_html_container_end();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_SettingsFields() , '__construct') ); // Executed after creation of Menu
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of item Listing page
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-11-13
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
|
||||
/** Show Content
|
||||
* Update Content
|
||||
* Define Slug
|
||||
* Define where to show
|
||||
*/
|
||||
class OPSD_Page_Main extends OPSD_Page_Structure {
|
||||
|
||||
private $listing_table;
|
||||
|
||||
public function in_page() {
|
||||
return 'opsd-files';
|
||||
}
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
$tabs[ 'vm_toolbar' ] = array(
|
||||
'title' => __('Item Listing', 'secure-downloads') // Title of TAB
|
||||
, 'hint' => __('Item Listing', 'secure-downloads') // Hint
|
||||
, 'page_title' => __('Item Listing', '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-tasks' // 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() {
|
||||
|
||||
opsd_check_request_paramters(); //Cleanup REQUEST parameters //FixIn:6.2.1.4
|
||||
|
||||
do_action( 'opsd_hook_opsd_page_header', array( 'page' => $this->in_page() ) ); // Define Notices Section and show some static messages, if needed.
|
||||
|
||||
?><span class="wpdevelop"><?php // BS UI CSS Class
|
||||
|
||||
make_opsd_action( 'opsd_write_content_for_modals' ); // Content for modal windows
|
||||
|
||||
opsd_js_for_items_page(); // JavaScript functions
|
||||
|
||||
make_opsd_action( 'opsd_check_request_param__wh_opsd_type' ); // Setting $_REQUEST['wh_opsd_type'] - remove empty and duplicates ID of item resources in this list
|
||||
|
||||
make_opsd_action( 'check_for_resources_of_notsuperadmin_in_opsd_listing' ); // If "Regular User", then filter resources in $_REQUEST['wh_opsd_type'] to show only resources of this user
|
||||
|
||||
|
||||
// T o o l b a r s /////////////////////////////////////////////////
|
||||
opsd_items_toolbar();
|
||||
|
||||
|
||||
?><div class="clear" style="height:40px;"></div><?php
|
||||
|
||||
$args = array( 'wh_opsd_type' => (isset( $_REQUEST[ 'wh_opsd_type' ] )) ? opsd_clean_parameter( $_REQUEST[ 'wh_opsd_type' ] ) : '' );
|
||||
echo '<textarea id="bk_request_params" style="display:none;">', serialize( $args ), '</textarea>';
|
||||
|
||||
$items = array(
|
||||
array(), array()
|
||||
);
|
||||
$opsd_types = array();
|
||||
$items_count = 100;
|
||||
$page_num = 1;
|
||||
$page_items_count= 10;
|
||||
|
||||
$this->listing_table = new OPSD_OPSD_Listing_Table( $items, $opsd_types );
|
||||
$this->listing_table->show();
|
||||
|
||||
|
||||
opsd_show_pagination($items_count, $page_num, $page_items_count); // Show Pagination
|
||||
|
||||
opsd_show_opsd_footer();
|
||||
|
||||
?></span><!-- wpdevelop class --><?php
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_Main() , '__construct') ); // Executed after creation of Menu
|
||||
|
||||
|
||||
|
||||
/** Trick here to overload default REQUST parameters before page is loading */
|
||||
function opsd_define_listing_page_parameters( $page_tag ) {
|
||||
|
||||
// $page_tag - here can be all defined in plugin menu pages
|
||||
// So we need to check activated page. By default its inside of $_GET['page'],
|
||||
|
||||
// Execute it only for item Listing admin pages.
|
||||
//if ( ( isset( $_GET[ 'page' ] ) ) && ( $_GET[ 'page' ] == 'opsd' ) ) {
|
||||
|
||||
if ( opsd_is_master_page() ) { // We are inside of this page. Menu item selected.
|
||||
// Get saved filters set, (if its not set in request yet), like "tab" & "view_mode" and overload $_REQUEST
|
||||
//$_REQUEST['view_mode'] = $opsd_default_view_mode; // Set to REQUEST
|
||||
}
|
||||
}
|
||||
// We are set 9 to execute early than hook in OPSD_Admin_Menus
|
||||
//add_action('opsd_define_nav_tabs', 'opsd_define_listing_page_parameters', 1 ); // This Hook fire in the class OPSD_Admin_Menus for showing page content of specific menu
|
||||
2
wp-content/plugins/secure-downloads/core/admin/index.php
Normal file
2
wp-content/plugins/secure-downloads/core/admin/index.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
@@ -0,0 +1,255 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Admin Panel - Dashboard functions
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2016-03-16
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// D a s h b o a r d W i d g e t
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Setup Widget for Dashboard */
|
||||
function opsd_dashboard_widget_setup(){
|
||||
|
||||
// Check, if we have permission to show Widget ///////////////////////////
|
||||
$is_user_activated = apply_opsd_filter('multiuser_is_current_user_active', true ); //FixIn: 6.0.1.17
|
||||
if ( ! $is_user_activated )
|
||||
return false;
|
||||
|
||||
$user_role = get_opsd_option( 'opsd_user_role_master' );
|
||||
if ( ! opsd_is_current_user_have_this_role( $user_role ) )
|
||||
return false;
|
||||
|
||||
|
||||
// Add Secure Downloads Widget to Dashboard ///////////////////////////////
|
||||
$bk_dashboard_widget_id = 'opsd_dashboard_widget';
|
||||
wp_add_dashboard_widget( $bk_dashboard_widget_id, sprintf( __( 'Item Calendar', 'secure-downloads') ), 'opsd_dashboard_widget_show', null );
|
||||
|
||||
|
||||
// Sort Dashboard. Add Secure Downloads widget to top ///////////////////////
|
||||
global $wp_meta_boxes;
|
||||
$normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
|
||||
if ( isset( $normal_dashboard[$bk_dashboard_widget_id] ) ) {
|
||||
// Backup and delete our new dashbaord widget from the end of the array
|
||||
$example_widget_backup = array( $bk_dashboard_widget_id => $normal_dashboard[$bk_dashboard_widget_id] );
|
||||
unset( $normal_dashboard[$bk_dashboard_widget_id] );
|
||||
} else
|
||||
$example_widget_backup = array();
|
||||
|
||||
// Sometimes, some other plugins can modify this item, so its can be not a array
|
||||
if ( is_array( $normal_dashboard ) ) {
|
||||
// Merge the two arrays together so our widget is at the beginning
|
||||
if ( is_array( $normal_dashboard ) )
|
||||
$sorted_dashboard = array_merge( $example_widget_backup, $normal_dashboard );
|
||||
else
|
||||
$sorted_dashboard = $example_widget_backup;
|
||||
// Save the sorted array back into the original metaboxes
|
||||
$wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
|
||||
}
|
||||
}
|
||||
//add_action( 'wp_dashboard_setup', 'opsd_dashboard_widget_setup' );
|
||||
|
||||
|
||||
|
||||
/** Show item Dashboard Widget content */
|
||||
function opsd_dashboard_widget_show() {
|
||||
|
||||
opsd_dashboard_widget_css();
|
||||
|
||||
?>
|
||||
<div id="opsd_dashboard_widget_container" >
|
||||
<?php
|
||||
|
||||
opsd_dashboard_section_version();
|
||||
|
||||
opsd_dashboard_section_support();
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/** Get Info for Dashboard */
|
||||
function opsd_get_dashboard_info() {
|
||||
|
||||
ob_start();
|
||||
|
||||
opsd_dashboard_widget_show();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
/** CSS for Dashboard Widget */
|
||||
function opsd_dashboard_widget_css() {
|
||||
|
||||
?><style type="text/css">
|
||||
#opsd_dashboard_widget_container {
|
||||
width:100%;
|
||||
}
|
||||
#opsd_dashboard_widget_container .opsd_dashboard_section {
|
||||
float:left;
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
width:100%;
|
||||
}
|
||||
#opsd_dashboard_widget_container .opsd_dashboard_section h4 {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin: 5px 0 15px;
|
||||
}
|
||||
#bk_upgrade_section p {
|
||||
font-size: 13px;
|
||||
line-height: 1.5em;
|
||||
margin: 15px 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
#dashboard-widgets-wrap #opsd_dashboard_widget_container .opsd_dashboard_section {
|
||||
width:49%;
|
||||
}
|
||||
#dashboard-widgets-wrap #opsd_dashboard_widget_container .bk_right {
|
||||
float:right
|
||||
}
|
||||
#dashboard-widgets-wrap #opsd_dashboard_widget_container .border_orrange,
|
||||
#opsd_dashboard_widget_container .border_orrange {
|
||||
background: #fffaf1 none repeat scroll 0 0;
|
||||
border-left: 3px solid #eeab26;
|
||||
clear: both;
|
||||
margin: 5px 5px 20px;
|
||||
padding: 10px 0;
|
||||
width: 99%;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_header {
|
||||
color: #555555;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1em;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table {
|
||||
background:transparent;
|
||||
border-bottom:none;
|
||||
border-top:1px solid #ECECEC;
|
||||
margin:6px 0 10px 6px;
|
||||
padding:2px 10px;
|
||||
width:95%;
|
||||
-border-radius:4px;
|
||||
-moz-border-radius:4px;
|
||||
-webkit-border-radius:4px;
|
||||
-moz-box-shadow:0 0 2px #C5C3C3;
|
||||
-webkit-box-shadow:0 0 2px #C5C3C3;
|
||||
-box-shadow:0 0 2px #C5C3C3;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td{
|
||||
border-bottom:1px solid #DDDDDD;
|
||||
line-height:19px;
|
||||
padding:4px 0px 4px 10px;
|
||||
font-size:13px;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table tr td.first{
|
||||
text-align:center;
|
||||
padding:4px 0px;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table tr td a {
|
||||
text-decoration: none;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table tr td a span{
|
||||
font-size:18px;
|
||||
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td.bk_spec_font a{
|
||||
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
|
||||
font-size:14px;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td.bk_spec_font {
|
||||
font-family: Georgia,"Times New Roman","Bitstream Charter",Times,serif;
|
||||
font-size:13px;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td.pending a{
|
||||
color:#E66F00;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td.new-items a{
|
||||
color:red;
|
||||
}
|
||||
#opsd_dashboard_widget_container .bk_table td.actual-items a{
|
||||
color:green;
|
||||
}
|
||||
#bk_errror_loading {
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
font-size:11px;
|
||||
}
|
||||
</style><?php
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// S e c t i o n s
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Dashboard Support Section */
|
||||
function opsd_dashboard_section_support() {
|
||||
?>
|
||||
<div class="opsd_dashboard_section bk_right">
|
||||
<span class="bk_header"><?php _e('Support' , 'secure-downloads');?>:</span>
|
||||
<table class="bk_table">
|
||||
<tr>
|
||||
<td style="text-align:center;" class="bk_spec_font"><a target="_blank" href="https://oplugins.com/plugins/secure-downloads/"><?php _e('Help Info' , 'secure-downloads');?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:center;" class="bk_spec_font"><a href="mailto:support@oplugins.com"><?php _e('Contact Support' , 'secure-downloads');?></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:center;" class="bk_spec_font"><?php
|
||||
printf( __( '%sNew feature suggestion%s', 'secure-downloads'),
|
||||
'<a href="mailto:newfeature@oplugins.com?Subject=Secure%20Downloads" target="_blank">',
|
||||
'</a>' ); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/** Dashboard Version Section */
|
||||
function opsd_dashboard_section_version() {
|
||||
|
||||
$version = 'free';
|
||||
|
||||
?>
|
||||
<div class="opsd_dashboard_section" >
|
||||
<span class="bk_header"><?php _e('Current version' , 'secure-downloads');?>:</span>
|
||||
<table class="bk_table">
|
||||
<tr class="first">
|
||||
<td style="width:35%;text-align: right;;" class=""><?php _e('Version' , 'secure-downloads');?>:</td>
|
||||
<td style="color: #e50;font-size: 13px;font-weight: 600;text-align: left;text-shadow: 0 -1px 0 #eee;;"
|
||||
class="bk_spec_font"><?php
|
||||
if ( substr( OPSD_VERSION, 0, 2 ) == '9.' ) {
|
||||
$show_version = substr( OPSD_VERSION , 2 ) ;
|
||||
if ( substr($show_version, ( -1 * ( strlen( OPSD_VERSION_NUM ) ) ) ) === OPSD_VERSION_NUM ) {
|
||||
$show_version = substr($show_version, 0, ( -1 * ( strlen( OPSD_VERSION_NUM ) ) - 1 ) );
|
||||
$show_version = str_replace('.', ' ', $show_version) . " <sup><strong style='font-size:12px;'>" . OPSD_VERSION_NUM . "</strong></sup>" ;
|
||||
}
|
||||
echo $show_version ;
|
||||
} else
|
||||
echo OPSD_VERSION;
|
||||
?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:35%;text-align: right;" class="first b"><?php _e('Release date' , 'secure-downloads');?>:</td>
|
||||
<td style="text-align: left; font-weight: 600;" class="bk_spec_font"><?php echo date ("d.m.Y", filemtime(OPSD_FILE)); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
1583
wp-content/plugins/secure-downloads/core/admin/opsd-toolbars.php
Normal file
1583
wp-content/plugins/secure-downloads/core/admin/opsd-toolbars.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,963 @@
|
||||
<?php
|
||||
/**
|
||||
* @version 1.0
|
||||
* @package Content
|
||||
* @category Menu
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-04-09
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/** Replace:
|
||||
1. DownloadNotification -> DownloadNotification
|
||||
2. DOWNLOAD_NOTIFICATION -> DOWNLOAD_NOTIFICATION
|
||||
3. download_notification -> download_notification
|
||||
4. Check in api-emails.php 'db_prefix_option' => '...' option, have to be the same as OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX here
|
||||
5. Configure Fields in init_settings_fields.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX' ) ) define( 'OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX', 'opsd_email_' ); // Its defined in api-emails.php file & its same for all emails, here its used only for easy coding...
|
||||
|
||||
if ( ! defined( 'OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID' ) ) define( 'OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID', 'download_notification' ); /* Define Name of Email Template.
|
||||
Note. Prefix "opsd_email_" defined in api-emails.php file.
|
||||
Full name of option is - "opsd_email_download_notification"
|
||||
Other email templates names:
|
||||
- 'download_notification' - send email with download link to user
|
||||
- 'link_admin' - send copy of email to admin with download link
|
||||
- 'download_admin' - send email about downloads happend
|
||||
*/
|
||||
|
||||
require_once( OPSD_PLUGIN_DIR . '/core/any/api-emails.php' ); // API
|
||||
|
||||
|
||||
/** Email F i e l d s */
|
||||
class OPSD_Emails_API_DownloadNotification extends OPSD_Emails_API { // O v e r r i d i n g "OPSD_Emails_API" ClASS
|
||||
|
||||
/** Overrided functions - define Email Fields & Values */
|
||||
public function init_settings_fields() {
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->fields['enabled'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => 'On'
|
||||
, 'title' => __('Enable / Disable', 'secure-downloads')
|
||||
, 'label' => __('Enable this email notification', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'general'
|
||||
|
||||
);
|
||||
/*
|
||||
$this->fields['copy_to_admin'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => 'On'
|
||||
, 'title' => __('Copy to admin', 'secure-downloads')
|
||||
, 'label' => __('Enable / disable sending copy of this email notification to admin', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'general'
|
||||
|
||||
);
|
||||
*/
|
||||
$this->fields['enabled_hr'] = array( 'type' => 'hr' );
|
||||
|
||||
$this->fields['to_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '<tr valign="top">
|
||||
<th scope="row">
|
||||
<label class="opsd-form-email" for="'
|
||||
. esc_attr( 'download_notification_to' )
|
||||
. '">' . wp_kses_post( __('To' , 'secure-downloads') )
|
||||
. '</label>
|
||||
</th>
|
||||
<td><fieldset style="float:left;width:50%;margin-right:5%;">'
|
||||
);
|
||||
$this->fields['to'] = array(
|
||||
'type' => 'text' // We are using here 'text' and not 'email', for ability to save several comma seperated emails.
|
||||
, 'default' => get_option( 'admin_email' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Email Address', 'secure-downloads') . '. ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
$this->fields['to_html_middle'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
|
||||
);
|
||||
|
||||
$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 : '';
|
||||
}
|
||||
|
||||
$this->fields['to_name'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => $user_info['name']
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Title', 'secure-downloads') . ' (' . __('optional', 'secure-downloads') . ').' //. ' ' . __('If empty then title defined as WordPress', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields['to_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => ' </fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
|
||||
|
||||
$this->fields['from_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '<tr valign="top">
|
||||
<th scope="row">
|
||||
<label class="opsd-form-email" for="'
|
||||
. esc_attr( 'download_notification_from' )
|
||||
. '">' . wp_kses_post( __('From' , 'secure-downloads') )
|
||||
. '</label>
|
||||
</th>
|
||||
<td><fieldset style="float:left;width:50%;margin-right:5%;">'
|
||||
);
|
||||
$this->fields['from'] = array(
|
||||
'type' => 'email' // Its can be only 1 email, so check it as Email field.
|
||||
, 'default' => get_option( 'admin_email' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Email Address', 'secure-downloads') . '. ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
$this->fields['from_html_middle'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
|
||||
);
|
||||
$this->fields['from_name'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => $user_info['name']
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Title', 'secure-downloads') . ' (' . __('optional', 'secure-downloads') . ').' //. ' ' . __('If empty then title defined as WordPress', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields['from_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => ' </fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$this->fields['from_hr'] = array( 'type' => 'hr' );
|
||||
|
||||
|
||||
$this->fields['subject'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => sprintf( __( 'Download notification of %s', 'secure-downloads'), '[product_title] [ [product_id] ]' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => __('Subject', 'secure-downloads')
|
||||
, 'description' => sprintf(__('Type your email %ssubject%s.' , 'secure-downloads'),'<b>','</b>') . ' ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
|
||||
$blg_title = get_option( 'blogname' );
|
||||
$blg_title = str_replace( array( '"', "'" ), '', $blg_title );
|
||||
|
||||
$this->fields['content'] = array(
|
||||
'type' => 'wp_textarea'
|
||||
, 'default' =>
|
||||
// sprintf( __( 'Hello.%sThe %s have been downloaded at %s from IP: %s~ Download link of %s will expire in %s === User info ===%s User agent: %s IP: %s Request url: %s ======================%s === Product Summary ===%s %s ======================%s Thank you, %s', 'secure-downloads' )
|
||||
// , '<br/><br/>'
|
||||
// , '[product_title] [ [product_id] ]'
|
||||
// , '[current_date] [current_time]'
|
||||
// , '[remote_ip]' . '<br/><br/>'
|
||||
// , '[product_filename] ([product_size])'
|
||||
// , '[product_expire_after] - [product_expire_date]' . '<br/><br/>'
|
||||
// , '<br/>'
|
||||
// , '[user_agent]' . '<br/>', '[remote_ip]' . '<br/>', '[request_url]' . '<br/>'
|
||||
// , '<br/><br/>'
|
||||
// , '<br/>'
|
||||
// , '[product_summary]<br/>[product_description]<br/>[product_link]<br/>'
|
||||
// , '<br/><br/>'
|
||||
// , $blg_title . '<br/>' . '[siteurl]'
|
||||
// )
|
||||
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' )
|
||||
, '<br/><br/>'
|
||||
, '<strong>[product_title] [product_version]</strong> [ID=[product_id]]'
|
||||
, '<br/><br/>'
|
||||
, '<br/>'
|
||||
, '[link_sent_to]' . '<br/>'
|
||||
, '[remote_ip]' . '<br/>'
|
||||
, '[user_agent]' . '<br/>'
|
||||
, '[request_url]' . '<br/>'
|
||||
, '<br/><br/>'
|
||||
, '<br/>[product_summary] <br/>[product_description] <br/>'
|
||||
, '<strong>[product_expire_date]</strong> '. '<br/>'
|
||||
, '<br/> <br/><strong>[current_date] [current_time]</strong>'
|
||||
)
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => __('Content', 'secure-downloads')
|
||||
, 'description' => __('Type your email message content.', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => ''
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'rows' => 10
|
||||
, 'show_in_2_cols' => true
|
||||
);
|
||||
// $this->fields['content'] = htmlspecialchars( $this->fields['content'] );// Convert > to >
|
||||
// $this->fields['content'] = html_entity_decode( $this->fields['content'] );// Convert > to >
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Style
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
$this->fields['header_content'] = array(
|
||||
'type' => 'textarea'
|
||||
, 'default' => ''
|
||||
, 'title' => __('Email Heading', 'secure-downloads')
|
||||
, 'description' => __('Enter main heading contained within the email notification.', 'secure-downloads')
|
||||
//, 'placeholder' => ''
|
||||
, 'rows' => 2
|
||||
, 'css' => "width:100%;"
|
||||
, 'group' => 'parts'
|
||||
);
|
||||
$this->fields['footer_content'] = array(
|
||||
'type' => 'textarea'
|
||||
, 'default' => ''
|
||||
, 'title' => __('Email Footer Text', 'secure-downloads')
|
||||
, 'description' => __('Enter text contained within footer of the email notification', 'secure-downloads')
|
||||
//, 'placeholder' => ''
|
||||
, 'rows' => 2
|
||||
, 'css' => 'width:100%;'
|
||||
, 'group' => 'parts'
|
||||
);
|
||||
|
||||
$this->fields['template_file'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => 'plain'
|
||||
, 'title' => __('Email template', 'secure-downloads')
|
||||
, 'description' => __('Choose email template.', 'secure-downloads')
|
||||
, 'description_tag' => 'span'
|
||||
, 'css' => ''
|
||||
, 'options' => array(
|
||||
'plain' => __('Plain (without styles)', 'secure-downloads')
|
||||
, 'standard' => __('Standard 1 column', 'secure-downloads')
|
||||
)
|
||||
, 'group' => 'style'
|
||||
);
|
||||
|
||||
$this->fields['template_file_help'] = array(
|
||||
'type' => 'help'
|
||||
, 'value' => array( sprintf( __('You can override this email template in this folder %s', 'secure-downloads')
|
||||
, '<code>' . realpath( dirname(__FILE__) . '/../any/emails_tpl/' ) . '</code>' )
|
||||
)
|
||||
, 'cols' => 2
|
||||
, 'group' => 'style'
|
||||
);
|
||||
|
||||
$this->fields['base_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#557da1'
|
||||
, 'title' => __('Base Color', 'secure-downloads')
|
||||
, 'description' => __('The base color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#557da1</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['background_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#f5f5f5'
|
||||
, 'title' => __('Background Color', 'secure-downloads')
|
||||
, 'description' => __('The background color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#f5f5f5</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['body_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#fdfdfd'
|
||||
, 'title' => __('Email Body Background Color', 'secure-downloads')
|
||||
, 'description' => __('The main body background color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#fdfdfd</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['text_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#505050'
|
||||
, 'title' => __('Email Body Text Colour', 'secure-downloads')
|
||||
, 'description' => __('The main body text color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#505050</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Email format: Plain, HTML, MultiPart
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
$this->fields['email_content_type'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => 'plain'
|
||||
, 'title' => __('Email format', 'secure-downloads')
|
||||
, 'description' => __('Choose which format of email to send.', 'secure-downloads')
|
||||
, 'description_tag' => 'p'
|
||||
, 'css' => 'width:100%;'
|
||||
, 'options' => array(
|
||||
'plain' => __('Plain text', 'secure-downloads')
|
||||
// , 'html' => __('HTML', 'secure-downloads')
|
||||
// , 'multipart' => __('Multipart', 'secure-downloads')
|
||||
)
|
||||
, 'group' => 'email_content_type'
|
||||
);
|
||||
if ( class_exists( 'DOMDocument' ) ) {
|
||||
$this->fields['email_content_type']['options']['html'] = __('HTML', 'secure-downloads');
|
||||
$this->fields['email_content_type']['options']['multipart'] = __('Multipart', 'secure-downloads');
|
||||
|
||||
$this->fields['email_content_type']['default'] = 'html';
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Help
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
$this->fields['content_help'] = array(
|
||||
'type' => 'help'
|
||||
, 'value' => array()
|
||||
, 'cols' => 2
|
||||
, 'group' => 'help'
|
||||
);
|
||||
|
||||
$skip_shortcodes = array(
|
||||
'denyreason'
|
||||
, 'paymentreason'
|
||||
, 'visitorediturl'
|
||||
, 'visitorcancelurl'
|
||||
, 'visitorpayurl'
|
||||
);
|
||||
$email_example = sprintf(__('For example: "You have a new reservation %s on the following date(s): %s Contact information: %s You can approve or cancel this item at: %s Thank you, Reservation service."' , 'secure-downloads'),'','[dates]<br/><br/>','<br/> [content]<br/><br/>', htmlentities( ' <a href="[moderatelink]">'.__('here' , 'secure-downloads').'</a> ') . '<br/><br/> ');
|
||||
|
||||
$help_fields = opsd_get_email_help_shortcodes( $skip_shortcodes, $email_example );
|
||||
|
||||
foreach ( $help_fields as $help_fields_key => $help_fields_value ) {
|
||||
$this->fields['content_help']['value'][] = $help_fields_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Settings Emails P a g e */
|
||||
class OPSD_Settings_Page_Email_DownloadNotification extends OPSD_Page_Structure {
|
||||
|
||||
public $email_settings_api = false;
|
||||
|
||||
|
||||
/** Define interface for Email API
|
||||
*
|
||||
* @param string $selected_email_name - name of Email template
|
||||
* @param array $init_fields_values - array of init form fields data
|
||||
* @return object Email API
|
||||
*/
|
||||
public function mail_api( $selected_email_name ='', $init_fields_values = array() ){
|
||||
|
||||
if ( $this->email_settings_api === false ) {
|
||||
$this->email_settings_api = new OPSD_Emails_API_DownloadNotification( $selected_email_name , $init_fields_values );
|
||||
}
|
||||
|
||||
return $this->email_settings_api;
|
||||
}
|
||||
|
||||
|
||||
public function in_page() { // P a g e t a g
|
||||
return 'opsd-settings';
|
||||
}
|
||||
|
||||
|
||||
public function tabs() { // T a b s A r r a y
|
||||
|
||||
$tabs = array();
|
||||
|
||||
$tabs[ 'email' ] = array(
|
||||
'title' => __( 'Emails', 'secure-downloads') // Title of TAB
|
||||
, 'page_title'=> __( 'Emails Settings', 'secure-downloads') // Title of Page
|
||||
, 'hint' => __( 'Emails Settings', 'secure-downloads') // Hint
|
||||
//, '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-envelope' // CSS definition of forn Icon
|
||||
//, 'default' => false // Is this tab activated by default or not: true || false.
|
||||
//, 'disabled' => false // Is this tab disbaled: true || false.
|
||||
//, 'hided' => false // Is this tab hided: true || false.
|
||||
, 'subtabs' => array()
|
||||
);
|
||||
|
||||
$subtabs = array();
|
||||
|
||||
|
||||
$is_data_exist = get_opsd_option( OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX . OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID ); // ''opsd_email_' - defined in api-emails.php file.
|
||||
if ( ( ! empty( $is_data_exist ) ) && ( isset( $is_data_exist['enabled'] ) ) && ( $is_data_exist['enabled'] == 'On' ) )
|
||||
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-check"></i> ';
|
||||
else
|
||||
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-unchecked"></i> ';
|
||||
|
||||
$subtabs['download-notification'] = array(
|
||||
'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
|
||||
, 'title' => $icon . __('Download Notification' , 'secure-downloads') // Title of TAB
|
||||
, 'page_title' => __('Emails Settings', 'secure-downloads') // Title of Page
|
||||
, 'hint' => __('Email about download notification, which is sending to admin' , 'secure-downloads') // Hint
|
||||
, 'link' => '' // link
|
||||
, 'position' => '' // 'left' || 'right' || ''
|
||||
, 'css_classes' => '' // CSS class(es)
|
||||
//, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
|
||||
//, 'font_icon' => 'glyphicon glyphicon-envelope' // CSS definition of Font Icon
|
||||
, 'default' => ! true // Is this sub tab activated by default or not: true || false.
|
||||
, 'disabled' => false // Is this sub tab deactivated: true || false.
|
||||
, 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
|
||||
, 'content' => 'content' // Function to load as conten of this TAB
|
||||
);
|
||||
|
||||
$tabs[ 'email' ]['subtabs'] = $subtabs;
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
|
||||
/** Show Content of Settings page */
|
||||
public function content() {
|
||||
//debuge( 'OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX . OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID, get_opsd_option( OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX . OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID )', OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX . OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID, get_opsd_option( OPSD_EMAIL_DOWNLOAD_NOTIFICATION_PREFIX . OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID ) );
|
||||
|
||||
$this->css();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Checking
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
do_action( 'opsd_hook_settings_page_header', array( 'page' => $this->in_page(), 'subpage' => 'emails_settings' ) ); // Define Notices Section and show some static messages, if needed.
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Load Data
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Its will load DATA from DB, during creattion mail_api CLASS
|
||||
* during initial activation of the API its try to get option from DB
|
||||
* We need to define this API before checking POST, to know all available fields
|
||||
* Define Email Name & define field values from DB, if not exist, then default values.
|
||||
Array (
|
||||
[opsd_email_download_notification] => Array
|
||||
(
|
||||
[enabled] => On
|
||||
[to] => beta@oplugins.com
|
||||
[to_name] => Some Name
|
||||
[from] => admin@oplugins.com
|
||||
[from_name] =>
|
||||
[subject] => New item
|
||||
[content] => You need to approve [shortcodetype] for: ...
|
||||
[header_content] =>
|
||||
[footer_content] =>
|
||||
[template_file] => plain
|
||||
[base_color] => #557da1
|
||||
[background_color] => #f5f5f5
|
||||
[body_color] => #fdfdfd
|
||||
[text_color] => #505050
|
||||
[email_content_type] => html
|
||||
)
|
||||
)
|
||||
|
||||
// $mail_api->save_to_db( $fields_values );
|
||||
*/
|
||||
$init_fields_values = array();
|
||||
|
||||
$this->mail_api( OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID, $init_fields_values );
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// S u b m i t Actions - S e n d
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name_action = 'opsd_form_action'; // Define form name
|
||||
if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name_action ] ) ) {
|
||||
|
||||
// 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_action ); // Its stop show anything on submiting, if its not refear to the original page
|
||||
|
||||
// Save Changes
|
||||
$this->update_actions();
|
||||
}
|
||||
?>
|
||||
<form name="<?php echo $submit_form_name_action; ?>" id="<?php echo $submit_form_name_action; ?>" action="" method="post" autocomplete="off">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name_action );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name_action; ?>" id="is_form_sbmitted_<?php echo $submit_form_name_action; ?>" value="1" />
|
||||
<input type="hidden" name="form_action" id="form_action" value="" />
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// S u b m i t Main Form
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name = 'opsd_emails_template'; // Define form name
|
||||
|
||||
$this->mail_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields before submit.
|
||||
|
||||
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
|
||||
$this->update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// JavaScript: Tooltips, Popover, Datepick (js & css)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo '<span class="wpdevelop">';
|
||||
|
||||
opsd_js_for_items_page();
|
||||
|
||||
echo '</span>';
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Content
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
|
||||
<span class="metabox-holder">
|
||||
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" autocomplete="off">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="metabox-holder">
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_left" >
|
||||
<?php
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'general', __('Email about download notification, which is sending to admin', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'general' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'parts' , __('Header / Footer', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'parts' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'style' , __('Email Styles', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'style' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_right">
|
||||
<?php
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'actions', __('Actions', 'secure-downloads') );
|
||||
|
||||
?><a class="button button-secondary" style="margin:0 0 5px;" href="javascript:void(0)"
|
||||
onclick="javascript: jQuery('#form_action').val('test_send'); jQuery('form#<?php echo $submit_form_name_action; ?>').trigger( 'submit' );"
|
||||
><?php _e('Send Test Email', 'secure-downloads'); ?></a><?php
|
||||
|
||||
?><input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary right" style="margin:0 0 5px 5px;" /><?php
|
||||
|
||||
/* ?>
|
||||
<a class="button button-secondary" href="javascript:void(0)" ><?php _e('Preview Email', 'secure-downloads'); ?></a>
|
||||
<hr />
|
||||
<a class="button button-secondary right"
|
||||
href="javascript:void(0)"
|
||||
onclick="javascript: if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to delete this item?', 'secure-downloads')); ?>') ){
|
||||
jQuery('#form_action').val('delete');
|
||||
jQuery('form#<?php echo $submit_form_name_action; ?>').trigger( 'submit' );
|
||||
}"
|
||||
><?php _e('Delete Email', 'secure-downloads'); ?></a>
|
||||
<?php */
|
||||
|
||||
?><div class="clear"></div><?php
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'email_content_type', __('Type', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'email_content_type' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'help', __('Help', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'help' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary" />
|
||||
</form>
|
||||
</span>
|
||||
<?php
|
||||
|
||||
$this->enqueue_js();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update form from Toolbar - create / delete/ load email templates
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_actions( ) {
|
||||
|
||||
|
||||
if ( $_POST['form_action'] == 'test_send' ) { // Sending test email
|
||||
|
||||
/*
|
||||
$this->email_settings_api = false;
|
||||
$selected_email_name = 'standard';
|
||||
$email_fields = get_opsd_option( 'opsd_email_' . $selected_email_name );
|
||||
$this->mail_api( $selected_email_name, $email_fields );
|
||||
*/
|
||||
|
||||
|
||||
//$to = sanitize_email( $this->mail_api()->fields_values['to'] );
|
||||
$replace = array ();
|
||||
$replace[ 'product_id' ] = '<strong>99</strong>';
|
||||
$replace[ 'product_title' ] = '<strong>Product ZZZ</strong>';
|
||||
$replace[ 'product_version' ] = '<strong>1.0</strong>';
|
||||
$replace[ 'product_description' ] = 'Product ZZZ Info';
|
||||
$replace[ 'product_filename' ] = 'zzz_product.zip';
|
||||
$replace[ 'product_link' ] = home_url();
|
||||
$replace[ 'product_size' ] = '3 Mb';
|
||||
$replace[ 'product_expire_after' ] = '1 day';
|
||||
$replace[ 'product_expire_date' ] = date_i18n( get_opsd_option( 'opsd_date_format' ) . ' ' . get_opsd_option( 'opsd_time_format' ), strtotime( '+1 day' ) );
|
||||
$replace[ 'product_summary' ] = '<a href="">' . $replace[ 'product_filename' ] . '</a> (' . $replace[ 'product_size' ] . ') ~ expire in ' . $replace[ 'product_expire_after' ];
|
||||
|
||||
$replace[ 'link_sent_to' ] = $this->mail_api()->get_from__email_address();
|
||||
|
||||
$replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . home_url() . '">' . home_url() . '</a>' );
|
||||
$replace[ 'remote_ip' ] = opsd_get_user_ip(); // The IP address from which the user is viewing the current page.
|
||||
$replace[ 'user_agent' ] = $_SERVER[ 'HTTP_USER_AGENT' ]; // Contents of the User-Agent: header from the current request, if there is one.
|
||||
$replace[ 'request_url' ] = $_SERVER[ 'HTTP_REFERER' ]; // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP
|
||||
$replace[ 'current_date' ] = date_i18n( get_opsd_option( 'opsd_date_format' ) );
|
||||
$replace[ 'current_time' ] = date_i18n( get_opsd_option( 'opsd_time_format' ) );
|
||||
|
||||
|
||||
$to = $this->mail_api()->get_from__email_address();
|
||||
$to_name = $this->mail_api()->get_from__name();
|
||||
$to = trim( $to_name ) . ' <' . $to . '> ';
|
||||
|
||||
$email_result = $this->mail_api()->send( $to , $replace );
|
||||
|
||||
if ( $email_result )
|
||||
opsd_show_message ( __('Email sent to ', 'secure-downloads') . ' ' . $this->mail_api()->get_from__email_address() , 5 );
|
||||
else
|
||||
opsd_show_message ( __('Email had not sent. Some error occuered.', 'secure-downloads'), 5 ,'error' );
|
||||
}
|
||||
|
||||
/*
|
||||
if ( $_POST['form_action'] == 'create' ) { // Create
|
||||
|
||||
$email_title = esc_attr( $_POST['create_email_template'] );
|
||||
$email_name = opsd_get_slug_format_4_option_name( $email_title );
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
|
||||
if ( empty($email_name) || isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template has not added.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
$opsd_email_tpl_names[ $email_name ]= stripslashes( $email_title );
|
||||
|
||||
update_opsd_option( 'opsd_email_tpl_names', $opsd_email_tpl_names );
|
||||
|
||||
opsd_show_message ( __('Email template added successfully', 'secure-downloads'), 5 ); // Show Save message
|
||||
|
||||
$redir = esc_url( add_query_arg( array('email_template' => $email_name ), html_entity_decode( $this->getUrl() ) ) );
|
||||
|
||||
opsd_reload_page_by_js( $redir );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $_POST['form_action'] == 'delete' ) { // Delete
|
||||
$email_name = esc_attr( $_POST['select_email_template'] );
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
if ( ! isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template does not exist.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($opsd_email_tpl_names[ $email_name ]); // Remove Email name from list of email names
|
||||
update_opsd_option( 'opsd_email_tpl_names', $opsd_email_tpl_names );
|
||||
|
||||
delete_opsd_option( 'opsd_email_' . $email_name ); // Delete Email Template
|
||||
|
||||
opsd_show_message ( __('Email template deleted successfully', 'secure-downloads'), 5 ); // Show Save message
|
||||
|
||||
|
||||
$redir = esc_url( remove_query_arg( array( 'email_template' ), html_entity_decode( $this->getUrl() ) ) ); // Load standard email template
|
||||
|
||||
opsd_reload_page_by_js( $redir );
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if ( $_POST['form_action'] == 'load' ) { // Load
|
||||
$email_name = $_POST['select_email_template'];
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
if ( ! isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template does not exist.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/** Update Email template to DB */
|
||||
public function update() {
|
||||
|
||||
// Get Validated Email fields
|
||||
$validated_fields = $this->mail_api()->validate_post();
|
||||
|
||||
//debuge($validated_fields);
|
||||
// Remove <p> at begining and </p> at END of email template.
|
||||
if (
|
||||
( substr( $validated_fields['content'], 0, 3) === '<p>' )
|
||||
&& ( substr( $validated_fields['content'], -4 ) === '</p>' )
|
||||
) {
|
||||
$validated_fields['content'] = substr ( $validated_fields['content'], 3, ( strlen ( $validated_fields['content'] ) - 7 ) );
|
||||
}
|
||||
|
||||
$this->mail_api()->save_to_db( $validated_fields );
|
||||
|
||||
opsd_show_message ( __('Settings saved.', 'secure-downloads'), 5 ); // Show Save message
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" CSS & JS " >
|
||||
|
||||
/** CSS for this page */
|
||||
private function css() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.opsd-help-message {
|
||||
border:none;
|
||||
margin:0 !important;
|
||||
padding:0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 399px) {
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Add Custon JavaScript - for some specific settings options
|
||||
* Executed After post content, after initial definition of settings, and possible definition after POST request.
|
||||
*
|
||||
* @param type $menu_slug
|
||||
*
|
||||
*/
|
||||
private function enqueue_js(){ // $page_tag, $active_page_tab, $active_page_subtab ) {
|
||||
|
||||
|
||||
|
||||
// Check if this correct page /////////////////////////////////////////////
|
||||
|
||||
// if ( !(
|
||||
// ( $page_tag == 'opsd-settings') // Load only at 'opsd-settings' menu
|
||||
// && ( $_GET['tab'] == 'email' ) // At ''general' tab
|
||||
// && ( ( ! isset( $_GET['subtab'] ) ) || ( $_GET['subtab'] == 'new-admin' ) )
|
||||
// )
|
||||
// ) return;
|
||||
|
||||
// JavaScript //////////////////////////////////////////////////////////////
|
||||
|
||||
$js_script = '';
|
||||
//Show or hide colors section in settings page depend form selected email template.
|
||||
$js_script .= " jQuery('select[name=\"download_notification_template_file\"]').on( 'change', function(){
|
||||
if ( jQuery('select[name=\"download_notification_template_file\"] option:selected').val() == 'plain' ) {
|
||||
jQuery('.template_colors').hide();
|
||||
} else {
|
||||
jQuery('.template_colors').show();
|
||||
}
|
||||
} ); ";
|
||||
$js_script .= "\n"; //New Line
|
||||
$js_script .= " if ( jQuery('select[name=\"download_notification_template_file\"] option:selected').val() == 'plain' ) {
|
||||
jQuery('.template_colors').hide();
|
||||
} ";
|
||||
|
||||
// Show Warning messages if Title (optional) is empty - title of email will be "WordPress
|
||||
$js_script .= " jQuery(document).ready(function(){ ";
|
||||
$js_script .= " if ( jQuery('#download_notification_to_name').val() == '' ) {";
|
||||
$js_script .= " jQuery('#download_notification_to_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
$js_script .= " if ( jQuery('#download_notification_from_name').val() == '' ) {";
|
||||
$js_script .= " jQuery('#download_notification_from_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
$js_script .= " }); ";
|
||||
// Show Warning messages if "From" Email DNS different from current website DNS
|
||||
$js_script .= " jQuery(document).ready(function(){ ";
|
||||
|
||||
$js_script .= " var opsd_email_from = jQuery('#download_notification_from').val();"; // from@oplugins.com
|
||||
$js_script .= " opsd_email_from = opsd_email_from.split('@');"; // ['from', 'oplugins.com']
|
||||
$js_script .= " opsd_email_from.shift();"; // ['oplugins.com']
|
||||
$js_script .= " opsd_email_from = opsd_email_from.join('');"; // 'oplugins.com'
|
||||
|
||||
$js_script .= " var opsd_website_dns = jQuery(location).attr('hostname');"; // server.com
|
||||
$js_script .= " if ( opsd_email_from != opsd_website_dns ) {";
|
||||
$js_script .= " jQuery('#download_notification_from').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('Email different from website DNS, its can be a reason of not delivery emails. Please use the email withing the same domain as your website!', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
|
||||
$js_script .= " }); ";
|
||||
|
||||
|
||||
|
||||
// Eneque JS to the footer of the page
|
||||
opsd_enqueue_js( $js_script );
|
||||
}
|
||||
|
||||
|
||||
// </editor-fold>
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Settings_Page_Email_DownloadNotification() , '__construct') ); // Executed after creation of Menu
|
||||
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Emails Sending After Download action " >
|
||||
|
||||
function opsd_send_email_download_notification( $replace = array(), $email_to = '' ) {
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Load Data
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Check if New Email Template Exist or NOT
|
||||
* Exist - return empty array in format: array( OPTION_NAME => array() )
|
||||
* Its will load DATA from DB, during creattion mail_api CLASS
|
||||
* during initial activation of the API its try to get option from DB
|
||||
* We need to define this API before checking POST, to know all available fields
|
||||
* Define Email Name & define field values from DB, if not exist, then default values.
|
||||
* Not Exist - import Old Data from DB
|
||||
* or get "default" data from settings and return array with this data
|
||||
* This data its initial parameters for definition fields in mail_api CLASS
|
||||
*
|
||||
*/
|
||||
|
||||
$init_fields_values = array();//opsd_import6_email__download_notification__get_fields_array_for_activation();
|
||||
|
||||
// Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table
|
||||
//$init_fields_values = array_shift( array_values( $init_fields_values ) );
|
||||
|
||||
$mail_api = new OPSD_Emails_API_DownloadNotification( OPSD_EMAIL_DOWNLOAD_NOTIFICATION_ID, $init_fields_values );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ( $mail_api->fields_values['enabled'] == 'Off' ) return false; // Email template deactivated - exit.
|
||||
|
||||
add_filter( 'opsd_email_api_is_allow_send_copy' , 'opsd_email_api_is_allow_send_copy_block' , 10, 3);
|
||||
|
||||
// Email
|
||||
if ( ! empty( $mail_api->fields_values['to'] ) ) // Admin email from Settings > Emails page
|
||||
$valid_email = sanitize_email( $mail_api->fields_values['to'] );
|
||||
// Overwrite email, if passed to function
|
||||
if ( ! empty( $to_email ) )
|
||||
$valid_email = sanitize_email( $to_email );
|
||||
|
||||
if ( empty( $valid_email ) ) return $mail_api; //return false;
|
||||
|
||||
// Name
|
||||
if ( ! empty( $mail_api->fields_values['to_name'] ) )
|
||||
$email_to_name = trim( wp_specialchars_decode( esc_html( stripslashes( $mail_api->fields_values['to_name'] ) ), ENT_QUOTES ) );
|
||||
else
|
||||
$email_to_name = '';
|
||||
|
||||
|
||||
$to = $email_to_name . ' <' . $valid_email . '> ';
|
||||
$email_result = $mail_api->send( $to , $replace );
|
||||
|
||||
//debuge( (int) $email_result, $to , $replace);
|
||||
|
||||
return $mail_api;
|
||||
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
@@ -0,0 +1,990 @@
|
||||
<?php
|
||||
/**
|
||||
* @version 1.0
|
||||
* @package Content
|
||||
* @category Menu
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-04-09
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/** Replace:
|
||||
1. LinkUser -> LinkUser
|
||||
2. LINK_USER -> LINK_USER
|
||||
3. link_user -> link_user
|
||||
4. Check in api-emails.php 'db_prefix_option' => '...' option, have to be the same as OPSD_EMAIL_LINK_USER_PREFIX here
|
||||
5. Configure Fields in init_settings_fields.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'OPSD_EMAIL_LINK_USER_PREFIX' ) ) define( 'OPSD_EMAIL_LINK_USER_PREFIX', 'opsd_email_' ); // Its defined in api-emails.php file & its same for all emails, here its used only for easy coding...
|
||||
|
||||
if ( ! defined( 'OPSD_EMAIL_LINK_USER_ID' ) ) define( 'OPSD_EMAIL_LINK_USER_ID', 'link_user' ); /* Define Name of Email Template.
|
||||
Note. Prefix "opsd_email_" defined in api-emails.php file.
|
||||
Full name of option is - "opsd_email_link_user"
|
||||
Other email templates names:
|
||||
- 'link_user' - send email with download link to user
|
||||
- 'link_admin' - send copy of email to admin with download link
|
||||
- 'download_admin' - send email about downloads happend
|
||||
*/
|
||||
|
||||
require_once( OPSD_PLUGIN_DIR . '/core/any/api-emails.php' ); // API
|
||||
|
||||
|
||||
/** Email F i e l d s */
|
||||
class OPSD_Emails_API_LinkUser extends OPSD_Emails_API { // O v e r r i d i n g "OPSD_Emails_API" ClASS
|
||||
|
||||
/** Overrided functions - define Email Fields & Values */
|
||||
public function init_settings_fields() {
|
||||
|
||||
$this->fields = array();
|
||||
|
||||
$this->fields['enabled'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => 'On'
|
||||
, 'title' => __('Enable / Disable', 'secure-downloads')
|
||||
, 'label' => __('Enable this email notification', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'general'
|
||||
|
||||
);
|
||||
|
||||
$this->fields['copy_to_admin'] = array(
|
||||
'type' => 'checkbox'
|
||||
, 'default' => 'On'
|
||||
, 'title' => __('Copy to admin', 'secure-downloads')
|
||||
, 'label' => __('Enable / disable sending copy of this email notification to admin', 'secure-downloads')
|
||||
, 'description' => ''
|
||||
, 'group' => 'general'
|
||||
|
||||
);
|
||||
|
||||
$this->fields['enabled_hr'] = array( 'type' => 'hr' );
|
||||
|
||||
$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 : '';
|
||||
}
|
||||
|
||||
/*
|
||||
$this->fields['to_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '<tr valign="top">
|
||||
<th scope="row">
|
||||
<label class="opsd-form-email" for="'
|
||||
. esc_attr( 'link_user_to' )
|
||||
. '">' . wp_kses_post( __('To' , 'secure-downloads') )
|
||||
. '</label>
|
||||
</th>
|
||||
<td><fieldset style="float:left;width:50%;margin-right:5%;">'
|
||||
);
|
||||
$this->fields['to'] = array(
|
||||
'type' => 'text' // We are using here 'text' and not 'email', for ability to save several comma seperated emails.
|
||||
, 'default' => get_option( 'admin_email' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Email Address', 'secure-downloads') . '. ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
$this->fields['to_html_middle'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
|
||||
);
|
||||
$this->fields['to_name'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => '' // $user_info['name']
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Title', 'secure-downloads') . ' (' . __('optional', 'secure-downloads') . ').' //. ' ' . __('If empty then title defined as WordPress', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields['to_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => ' </fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
$this->fields['from_html_prefix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '<tr valign="top">
|
||||
<th scope="row">
|
||||
<label class="opsd-form-email" for="'
|
||||
. esc_attr( 'link_user_from' )
|
||||
. '">' . wp_kses_post( __('From' , 'secure-downloads') )
|
||||
. '</label>
|
||||
</th>
|
||||
<td><fieldset style="float:left;width:50%;margin-right:5%;">'
|
||||
);
|
||||
$this->fields['from'] = array(
|
||||
'type' => 'email' // Its can be only 1 email, so check it as Email field.
|
||||
, 'default' => get_option( 'admin_email' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Email Address', 'secure-downloads') . '. ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
$this->fields['from_html_middle'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => '</fieldset><fieldset style="float:left;width:45%;">'
|
||||
);
|
||||
$this->fields['from_name'] = array(
|
||||
'type' => 'text'
|
||||
, 'default' => $user_info['name']
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => ''
|
||||
, 'description' => __('Title', 'secure-downloads') . ' (' . __('optional', 'secure-downloads') . ').' //. ' ' . __('If empty then title defined as WordPress', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
);
|
||||
$this->fields['from_html_sufix'] = array(
|
||||
'type' => 'pure_html'
|
||||
, 'group' => 'general'
|
||||
, 'html' => ' </fieldset>
|
||||
</td>
|
||||
</tr>'
|
||||
);
|
||||
|
||||
$this->fields['from_hr'] = array( 'type' => 'hr' );
|
||||
|
||||
|
||||
$this->fields['subject'] = array(
|
||||
'type' => 'text'
|
||||
// , 'default' => sprintf( __( 'Update of %s', 'secure-downloads'), '[product_title]' )
|
||||
, 'default' => sprintf( __( 'Delivery of %s', 'secure-downloads'), '[product_title] [product_version]' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => __('Subject', 'secure-downloads')
|
||||
, 'description' => sprintf(__('Type your email %ssubject%s.' , 'secure-downloads'),'<b>','</b>') . ' ' . __('Required', 'secure-downloads') . '.'
|
||||
, 'description_tag' => ''
|
||||
, 'css' => 'width:100%'
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'validate_as' => array( 'required' )
|
||||
);
|
||||
|
||||
$blg_title = get_option( 'blogname' );
|
||||
$blg_title = str_replace( array( '"', "'" ), '', $blg_title );
|
||||
|
||||
$this->fields['content'] = array(
|
||||
'type' => 'wp_textarea'
|
||||
// , 'default' => sprintf( __( 'Hello.%sTo download %s click the link below:%s (%s) ~ Download link will expire in %sThank you, %s', 'secure-downloads')
|
||||
// , '<br/><br/>', '[product_title]', '<br/>[product_link]', '[product_size]', '[product_expire_after]<br/><br/>', '[site_title]<br>[siteurl]' )
|
||||
, 'default' => sprintf( __( 'Hello. %sThank you for requesting %s To download %s click the link below: %s Thank you, %s', 'secure-downloads' )
|
||||
, '<br/>'
|
||||
, '[product_title] [product_version]<br/><br/>'
|
||||
, '<strong>[product_description]</strong>'
|
||||
, '<br/> --- <br/> [product_summary] - [product_expire_date] <br/> --- <br/> <br/> '
|
||||
, '[siteurl]<br/> [current_date] [current_time]' )
|
||||
//, 'placeholder' => ''
|
||||
, 'title' => __('Content', 'secure-downloads')
|
||||
, 'description' => __('Type your email message content.', 'secure-downloads')
|
||||
, 'description_tag' => ''
|
||||
, 'css' => ''
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'rows' => 10
|
||||
, 'show_in_2_cols' => true
|
||||
);
|
||||
// $this->fields['content'] = htmlspecialchars( $this->fields['content'] );// Convert > to >
|
||||
// $this->fields['content'] = html_entity_decode( $this->fields['content'] );// Convert > to >
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Style
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
$this->fields['header_content'] = array(
|
||||
'type' => 'textarea'
|
||||
, 'default' => ''
|
||||
, 'title' => __('Email Heading', 'secure-downloads')
|
||||
, 'description' => __('Enter main heading contained within the email notification.', 'secure-downloads')
|
||||
//, 'placeholder' => ''
|
||||
, 'rows' => 2
|
||||
, 'css' => "width:100%;"
|
||||
, 'group' => 'parts'
|
||||
);
|
||||
$this->fields['footer_content'] = array(
|
||||
'type' => 'textarea'
|
||||
, 'default' => ''
|
||||
, 'title' => __('Email Footer Text', 'secure-downloads')
|
||||
, 'description' => __('Enter text contained within footer of the email notification', 'secure-downloads')
|
||||
//, 'placeholder' => ''
|
||||
, 'rows' => 2
|
||||
, 'css' => 'width:100%;'
|
||||
, 'group' => 'parts'
|
||||
);
|
||||
|
||||
$this->fields['template_file'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => 'plain'
|
||||
, 'title' => __('Email template', 'secure-downloads')
|
||||
, 'description' => __('Choose email template.', 'secure-downloads')
|
||||
, 'description_tag' => 'span'
|
||||
, 'css' => ''
|
||||
, 'options' => array(
|
||||
'plain' => __('Plain (without styles)', 'secure-downloads')
|
||||
, 'standard' => __('Standard 1 column', 'secure-downloads')
|
||||
)
|
||||
, 'group' => 'style'
|
||||
);
|
||||
|
||||
$this->fields['template_file_help'] = array(
|
||||
'type' => 'help'
|
||||
, 'value' => array( sprintf( __('You can override this email template in this folder %s', 'secure-downloads')
|
||||
, '<code>' . realpath( dirname(__FILE__) . '/../any/emails_tpl/' ) . '</code>' )
|
||||
)
|
||||
, 'cols' => 2
|
||||
, 'group' => 'style'
|
||||
);
|
||||
|
||||
$this->fields['base_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#557da1'
|
||||
, 'title' => __('Base Color', 'secure-downloads')
|
||||
, 'description' => __('The base color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#557da1</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['background_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#f5f5f5'
|
||||
, 'title' => __('Background Color', 'secure-downloads')
|
||||
, 'description' => __('The background color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#f5f5f5</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['body_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#fdfdfd'
|
||||
, 'title' => __('Email Body Background Color', 'secure-downloads')
|
||||
, 'description' => __('The main body background color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#fdfdfd</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
$this->fields['text_color'] = array(
|
||||
'type' => 'color'
|
||||
, 'default' => '#505050'
|
||||
, 'title' => __('Email Body Text Colour', 'secure-downloads')
|
||||
, 'description' => __('The main body text color for email templates.', 'secure-downloads')
|
||||
. ' ' . __('Default color', 'secure-downloads') .': <code>#505050</code>.'
|
||||
, 'group' => 'style'
|
||||
, 'tr_class' => 'template_colors'
|
||||
);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Email format: Plain, HTML, MultiPart
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
$this->fields['email_content_type'] = array(
|
||||
'type' => 'select'
|
||||
, 'default' => 'plain'
|
||||
, 'title' => __('Email format', 'secure-downloads')
|
||||
, 'description' => __('Choose which format of email to send.', 'secure-downloads')
|
||||
, 'description_tag' => 'p'
|
||||
, 'css' => 'width:100%;'
|
||||
, 'options' => array(
|
||||
'plain' => __('Plain text', 'secure-downloads')
|
||||
// , 'html' => __('HTML', 'secure-downloads')
|
||||
// , 'multipart' => __('Multipart', 'secure-downloads')
|
||||
)
|
||||
, 'group' => 'email_content_type'
|
||||
);
|
||||
if ( class_exists( 'DOMDocument' ) ) {
|
||||
$this->fields['email_content_type']['options']['html'] = __('HTML', 'secure-downloads');
|
||||
$this->fields['email_content_type']['options']['multipart'] = __('Multipart', 'secure-downloads');
|
||||
|
||||
$this->fields['email_content_type']['default'] = 'html';
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Help
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
$this->fields['content_help'] = array(
|
||||
'type' => 'help'
|
||||
, 'value' => array()
|
||||
, 'cols' => 2
|
||||
, 'group' => 'help'
|
||||
);
|
||||
|
||||
$skip_shortcodes = array(
|
||||
'denyreason'
|
||||
, 'paymentreason'
|
||||
, 'visitorediturl'
|
||||
, 'visitorcancelurl'
|
||||
, 'visitorpayurl'
|
||||
);
|
||||
$email_example = sprintf(__('For example: "You have a new reservation %s on the following date(s): %s Contact information: %s You can approve or cancel this item at: %s Thank you, Reservation service."' , 'secure-downloads'),'','[dates]<br/><br/>','<br/> [content]<br/><br/>', htmlentities( ' <a href="[moderatelink]">'.__('here' , 'secure-downloads').'</a> ') . '<br/><br/> ');
|
||||
|
||||
$help_fields = opsd_get_email_help_shortcodes( $skip_shortcodes, $email_example );
|
||||
|
||||
foreach ( $help_fields as $help_fields_key => $help_fields_value ) {
|
||||
$this->fields['content_help']['value'][] = $help_fields_value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Settings Emails P a g e */
|
||||
class OPSD_Settings_Page_Email_LinkUser extends OPSD_Page_Structure {
|
||||
|
||||
// Addon Fix
|
||||
public function __construct() {
|
||||
$is_show = true;
|
||||
$is_show = apply_filters( 'opsd_is_show_email_link_user_page', $is_show );
|
||||
if ( $is_show )
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public $email_settings_api = false;
|
||||
|
||||
|
||||
/** Define interface for Email API
|
||||
*
|
||||
* @param string $selected_email_name - name of Email template
|
||||
* @param array $init_fields_values - array of init form fields data
|
||||
* @return object Email API
|
||||
*/
|
||||
public function mail_api( $selected_email_name ='', $init_fields_values = array() ){
|
||||
|
||||
if ( $this->email_settings_api === false ) {
|
||||
$this->email_settings_api = new OPSD_Emails_API_LinkUser( $selected_email_name , $init_fields_values );
|
||||
}
|
||||
|
||||
return $this->email_settings_api;
|
||||
}
|
||||
|
||||
|
||||
public function in_page() { // P a g e t a g
|
||||
return 'opsd-settings';
|
||||
}
|
||||
|
||||
|
||||
public function tabs() { // T a b s A r r a y
|
||||
|
||||
$tabs = array();
|
||||
|
||||
$tabs[ 'email' ] = array(
|
||||
'title' => __( 'Emails', 'secure-downloads') // Title of TAB
|
||||
, 'page_title'=> __( 'Emails Settings', 'secure-downloads') // Title of Page
|
||||
, 'hint' => __( 'Emails Settings', 'secure-downloads') // Hint
|
||||
//, '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-envelope' // CSS definition of forn Icon
|
||||
//, 'default' => false // Is this tab activated by default or not: true || false.
|
||||
//, 'disabled' => false // Is this tab disbaled: true || false.
|
||||
//, 'hided' => false // Is this tab hided: true || false.
|
||||
, 'subtabs' => array()
|
||||
);
|
||||
|
||||
$subtabs = array();
|
||||
|
||||
|
||||
$is_data_exist = get_opsd_option( OPSD_EMAIL_LINK_USER_PREFIX . OPSD_EMAIL_LINK_USER_ID ); // ''opsd_email_' - defined in api-emails.php file.
|
||||
if ( ( ! empty( $is_data_exist ) ) && ( isset( $is_data_exist['enabled'] ) ) && ( $is_data_exist['enabled'] == 'On' ) )
|
||||
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-check"></i> ';
|
||||
else
|
||||
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-unchecked"></i> ';
|
||||
|
||||
if ( ( ! empty( $is_data_exist ) ) && ( isset( $is_data_exist['copy_to_admin'] ) ) && ( $is_data_exist['copy_to_admin'] == 'On' ) )
|
||||
$sufix = '<sup> 2</sup>';
|
||||
else
|
||||
$sufix = '';
|
||||
|
||||
$subtabs['link-user'] = array(
|
||||
'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
|
||||
, 'title' => $icon . __('To User' , 'secure-downloads') . $sufix // Title of TAB
|
||||
, 'page_title' => __('Emails Settings', 'secure-downloads') // Title of Page
|
||||
, 'hint' => __('Email with download link, which is sending to user' , 'secure-downloads') // Hint
|
||||
, 'link' => '' // link
|
||||
, 'position' => '' // 'left' || 'right' || ''
|
||||
, 'css_classes' => '' // CSS class(es)
|
||||
//, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
|
||||
//, 'font_icon' => 'glyphicon glyphicon-envelope' // CSS definition of Font Icon
|
||||
, 'default' => true // Is this sub tab activated by default or not: true || false.
|
||||
, 'disabled' => false // Is this sub tab deactivated: true || false.
|
||||
, 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
|
||||
, 'content' => 'content' // Function to load as conten of this TAB
|
||||
);
|
||||
|
||||
$tabs[ 'email' ]['subtabs'] = $subtabs;
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
|
||||
/** Show Content of Settings page */
|
||||
public function content() {
|
||||
//debuge( 'OPSD_EMAIL_LINK_USER_PREFIX . OPSD_EMAIL_LINK_USER_ID, get_opsd_option( OPSD_EMAIL_LINK_USER_PREFIX . OPSD_EMAIL_LINK_USER_ID )', OPSD_EMAIL_LINK_USER_PREFIX . OPSD_EMAIL_LINK_USER_ID, get_opsd_option( OPSD_EMAIL_LINK_USER_PREFIX . OPSD_EMAIL_LINK_USER_ID ) );
|
||||
|
||||
$this->css();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Checking
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
do_action( 'opsd_hook_settings_page_header', array( 'page' => $this->in_page(), 'subpage' => 'emails_settings' ) ); // Define Notices Section and show some static messages, if needed.
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Load Data
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/** Its will load DATA from DB, during creattion mail_api CLASS
|
||||
* during initial activation of the API its try to get option from DB
|
||||
* We need to define this API before checking POST, to know all available fields
|
||||
* Define Email Name & define field values from DB, if not exist, then default values.
|
||||
Array (
|
||||
[opsd_email_link_user] => Array
|
||||
(
|
||||
[enabled] => On
|
||||
[to] => beta@oplugins.com
|
||||
[to_name] => 'Some name'
|
||||
[from] => admin@oplugins.com
|
||||
[from_name] =>
|
||||
[subject] => New item
|
||||
[content] => You need to approve [shortcodetype] for: [dates]...
|
||||
[header_content] =>
|
||||
[footer_content] =>
|
||||
[template_file] => plain
|
||||
[base_color] => #557da1
|
||||
[background_color] => #f5f5f5
|
||||
[body_color] => #fdfdfd
|
||||
[text_color] => #505050
|
||||
[email_content_type] => html
|
||||
)
|
||||
)
|
||||
|
||||
// $mail_api->save_to_db( $fields_values );
|
||||
*/
|
||||
$init_fields_values = array();
|
||||
|
||||
$this->mail_api( OPSD_EMAIL_LINK_USER_ID, $init_fields_values );
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// S u b m i t Actions - S e n d
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name_action = 'opsd_form_action'; // Define form name
|
||||
if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name_action ] ) ) {
|
||||
|
||||
// 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_action ); // Its stop show anything on submiting, if its not refear to the original page
|
||||
|
||||
// Save Changes
|
||||
$this->update_actions();
|
||||
}
|
||||
?>
|
||||
<form name="<?php echo $submit_form_name_action; ?>" id="<?php echo $submit_form_name_action; ?>" action="" method="post" autocomplete="off">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name_action );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name_action; ?>" id="is_form_sbmitted_<?php echo $submit_form_name_action; ?>" value="1" />
|
||||
<input type="hidden" name="form_action" id="form_action" value="" />
|
||||
</form>
|
||||
<?php
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// S u b m i t Main Form
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name = 'opsd_emails_template'; // Define form name
|
||||
|
||||
$this->mail_api()->validated_form_id = $submit_form_name; // Define ID of Form for ability to validate fields before submit.
|
||||
|
||||
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
|
||||
$this->update();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// JavaScript: Tooltips, Popover, Datepick (js & css)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
echo '<span class="wpdevelop">';
|
||||
|
||||
opsd_js_for_items_page();
|
||||
|
||||
echo '</span>';
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Content
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
|
||||
<span class="metabox-holder">
|
||||
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" autocomplete="off">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="metabox-holder">
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_left" >
|
||||
<?php
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'general', __('Email with download link, which is sending to user', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'general' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'parts' , __('Header / Footer', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'parts' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'style' , __('Email Styles', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'style' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_right">
|
||||
<?php
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'actions', __('Actions', 'secure-downloads') );
|
||||
|
||||
?><a class="button button-secondary" style="margin:0 0 5px;" href="javascript:void(0)"
|
||||
onclick="javascript: jQuery('#form_action').val('test_send'); jQuery('form#<?php echo $submit_form_name_action; ?>').trigger( 'submit' );"
|
||||
><?php _e('Send Test Email', 'secure-downloads'); ?></a><?php
|
||||
|
||||
?><input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary right" style="margin:0 0 5px 5px;" /><?php
|
||||
|
||||
/* ?>
|
||||
<a class="button button-secondary" href="javascript:void(0)" ><?php _e('Preview Email', 'secure-downloads'); ?></a>
|
||||
<hr />
|
||||
<a class="button button-secondary right"
|
||||
href="javascript:void(0)"
|
||||
onclick="javascript: if ( opsd_are_you_sure('<?php echo esc_js(__('Do you really want to delete this item?', 'secure-downloads')); ?>') ){
|
||||
jQuery('#form_action').val('delete');
|
||||
jQuery('form#<?php echo $submit_form_name_action; ?>').trigger( 'submit' );
|
||||
}"
|
||||
><?php _e('Delete Email', 'secure-downloads'); ?></a>
|
||||
<?php */
|
||||
|
||||
?><div class="clear"></div><?php
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'email_content_type', __('Type', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'email_content_type' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
|
||||
opsd_open_meta_box_section( $submit_form_name . 'help', __('Help', 'secure-downloads') );
|
||||
|
||||
$this->mail_api()->show( 'help' );
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary" />
|
||||
</form>
|
||||
</span>
|
||||
<?php
|
||||
|
||||
$this->enqueue_js();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update form from Toolbar - create / delete/ load email templates
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function update_actions( ) {
|
||||
|
||||
|
||||
if ( $_POST['form_action'] == 'test_send' ) { // Sending test email
|
||||
|
||||
/*
|
||||
$this->email_settings_api = false;
|
||||
$selected_email_name = 'standard';
|
||||
$email_fields = get_opsd_option( 'opsd_email_' . $selected_email_name );
|
||||
$this->mail_api( $selected_email_name, $email_fields );
|
||||
*/
|
||||
|
||||
|
||||
//$to = sanitize_email( $this->mail_api()->fields_values['to'] );
|
||||
|
||||
$replace = array();
|
||||
$replace[ 'product_id' ] = '<strong>99</strong>';
|
||||
$replace[ 'product_title' ] = '<strong>Product ZZZ</strong>';
|
||||
$replace[ 'product_version' ] = '<strong>1.0</strong>';
|
||||
$replace[ 'product_description' ] = 'Product ZZZ Info';
|
||||
$replace[ 'product_filename' ] = 'zzz_product.zip';
|
||||
$replace[ 'product_link' ] = home_url();
|
||||
$replace[ 'product_size' ] = '3 Mb';
|
||||
$replace[ 'product_expire_after' ] = '1 day';
|
||||
$replace[ 'product_expire_date' ] = date_i18n( get_opsd_option( 'opsd_date_format' ) . ' ' . get_opsd_option( 'opsd_time_format' ), strtotime( '+1 day' ) );
|
||||
$replace[ 'product_summary' ] = '<a href="">' . $replace[ 'product_filename' ] . '</a> (' . $replace[ 'product_size' ] . ') ~ expire in ' . $replace[ 'product_expire_after' ];
|
||||
|
||||
$replace[ 'link_sent_to' ] = $this->mail_api()->get_from__email_address();
|
||||
|
||||
$replace[ 'siteurl' ] = htmlspecialchars_decode( '<a href="' . home_url() . '">' . home_url() . '</a>' );
|
||||
$replace[ 'remote_ip' ] = opsd_get_user_ip(); // The IP address from which the user is viewing the current page.
|
||||
$replace[ 'user_agent' ] = $_SERVER[ 'HTTP_USER_AGENT' ]; // Contents of the User-Agent: header from the current request, if there is one.
|
||||
$replace[ 'request_url' ] = $_SERVER[ 'HTTP_REFERER' ]; // The address of the page (if any) where action was occured. Because we are sending it in Ajax request, we need to use the REFERER HTTP
|
||||
$replace[ 'current_date' ] = date_i18n( get_opsd_option( 'opsd_date_format' ) );
|
||||
$replace[ 'current_time' ] = date_i18n( get_opsd_option( 'opsd_time_format' ) );
|
||||
|
||||
|
||||
|
||||
$to = $this->mail_api()->get_from__email_address();
|
||||
$to_name = $this->mail_api()->get_from__name();
|
||||
$to = trim( $to_name ) . ' <' . $to . '> ';
|
||||
|
||||
$email_result = $this->mail_api()->send( $to , $replace );
|
||||
|
||||
if ( $email_result )
|
||||
opsd_show_message ( __('Email sent to ', 'secure-downloads') . ' ' . $this->mail_api()->get_from__email_address() , 5 );
|
||||
else
|
||||
opsd_show_message ( __('Email had not sent. Some error occuered.', 'secure-downloads'), 5 ,'error' );
|
||||
}
|
||||
|
||||
/*
|
||||
if ( $_POST['form_action'] == 'create' ) { // Create
|
||||
|
||||
$email_title = esc_attr( $_POST['create_email_template'] );
|
||||
$email_name = opsd_get_slug_format_4_option_name( $email_title );
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
|
||||
if ( empty($email_name) || isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template has not added.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
$opsd_email_tpl_names[ $email_name ]= stripslashes( $email_title );
|
||||
|
||||
update_opsd_option( 'opsd_email_tpl_names', $opsd_email_tpl_names );
|
||||
|
||||
opsd_show_message ( __('Email template added successfully', 'secure-downloads'), 5 ); // Show Save message
|
||||
|
||||
$redir = esc_url( add_query_arg( array('email_template' => $email_name ), html_entity_decode( $this->getUrl() ) ) );
|
||||
|
||||
opsd_reload_page_by_js( $redir );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( $_POST['form_action'] == 'delete' ) { // Delete
|
||||
$email_name = esc_attr( $_POST['select_email_template'] );
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
if ( ! isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template does not exist.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($opsd_email_tpl_names[ $email_name ]); // Remove Email name from list of email names
|
||||
update_opsd_option( 'opsd_email_tpl_names', $opsd_email_tpl_names );
|
||||
|
||||
delete_opsd_option( 'opsd_email_' . $email_name ); // Delete Email Template
|
||||
|
||||
opsd_show_message ( __('Email template deleted successfully', 'secure-downloads'), 5 ); // Show Save message
|
||||
|
||||
|
||||
$redir = esc_url( remove_query_arg( array( 'email_template' ), html_entity_decode( $this->getUrl() ) ) ); // Load standard email template
|
||||
|
||||
opsd_reload_page_by_js( $redir );
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if ( $_POST['form_action'] == 'load' ) { // Load
|
||||
$email_name = $_POST['select_email_template'];
|
||||
|
||||
$opsd_email_tpl_names = get_opsd_option( 'opsd_email_tpl_names' );
|
||||
if ( empty( $opsd_email_tpl_names ) ) $opsd_email_tpl_names = array();
|
||||
|
||||
if ( ! isset( $opsd_email_tpl_names[ $email_name ] ) ) { // Error
|
||||
opsd_show_message ( __('Email template does not exist.', 'secure-downloads'), 5 , 'error' );
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
/** Update Email template to DB */
|
||||
public function update() {
|
||||
|
||||
// Get Validated Email fields
|
||||
$validated_fields = $this->mail_api()->validate_post();
|
||||
|
||||
// Remove <p> at begining and </p> at END of email template.
|
||||
if (
|
||||
( substr( $validated_fields['content'], 0, 3) === '<p>' )
|
||||
&& ( substr( $validated_fields['content'], -4 ) === '</p>' )
|
||||
) {
|
||||
$validated_fields['content'] = substr ( $validated_fields['content'], 3, ( strlen ( $validated_fields['content'] ) - 7 ) );
|
||||
}
|
||||
|
||||
$this->mail_api()->save_to_db( $validated_fields );
|
||||
|
||||
opsd_show_message ( __('Settings saved.', 'secure-downloads'), 5 ); // Show Save message
|
||||
}
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" CSS & JS " >
|
||||
|
||||
/** CSS for this page */
|
||||
private function css() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.opsd-help-message {
|
||||
border:none;
|
||||
margin:0 !important;
|
||||
padding:0 !important;
|
||||
}
|
||||
|
||||
@media (max-width: 399px) {
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Add Custon JavaScript - for some specific settings options
|
||||
* Executed After post content, after initial definition of settings, and possible definition after POST request.
|
||||
*
|
||||
* @param type $menu_slug
|
||||
*
|
||||
*/
|
||||
private function enqueue_js(){ // $page_tag, $active_page_tab, $active_page_subtab ) {
|
||||
|
||||
|
||||
|
||||
// Check if this correct page /////////////////////////////////////////////
|
||||
|
||||
// if ( !(
|
||||
// ( $page_tag == 'opsd-settings') // Load only at 'opsd-settings' menu
|
||||
// && ( $_GET['tab'] == 'email' ) // At ''general' tab
|
||||
// && ( ( ! isset( $_GET['subtab'] ) ) || ( $_GET['subtab'] == 'new-admin' ) )
|
||||
// )
|
||||
// ) return;
|
||||
|
||||
// JavaScript //////////////////////////////////////////////////////////////
|
||||
|
||||
$js_script = '';
|
||||
//Show or hide colors section in settings page depend form selected email template.
|
||||
$js_script .= " jQuery('select[name=\"link_user_template_file\"]').on( 'change', function(){
|
||||
if ( jQuery('select[name=\"link_user_template_file\"] option:selected').val() == 'plain' ) {
|
||||
jQuery('.template_colors').hide();
|
||||
} else {
|
||||
jQuery('.template_colors').show();
|
||||
}
|
||||
} ); ";
|
||||
$js_script .= "\n"; //New Line
|
||||
$js_script .= " if ( jQuery('select[name=\"link_user_template_file\"] option:selected').val() == 'plain' ) {
|
||||
jQuery('.template_colors').hide();
|
||||
} ";
|
||||
|
||||
// Show Warning messages if Title (optional) is empty - title of email will be "WordPress
|
||||
$js_script .= " jQuery(document).ready(function(){ ";
|
||||
$js_script .= " if ( jQuery('#link_user_to_name').val() == '' ) {";
|
||||
$js_script .= " jQuery('#link_user_to_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
$js_script .= " if ( jQuery('#link_user_from_name').val() == '' ) {";
|
||||
$js_script .= " jQuery('#link_user_from_name').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('If empty then title defined as WordPress', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
$js_script .= " }); ";
|
||||
// Show Warning messages if "From" Email DNS different from current website DNS
|
||||
$js_script .= " jQuery(document).ready(function(){ ";
|
||||
|
||||
$js_script .= " var opsd_email_from = jQuery('#link_user_from').val();"; // from@oplugins.com
|
||||
$js_script .= " opsd_email_from = opsd_email_from.split('@');"; // ['from', 'oplugins.com']
|
||||
$js_script .= " opsd_email_from.shift();"; // ['oplugins.com']
|
||||
$js_script .= " opsd_email_from = opsd_email_from.join('');"; // 'oplugins.com'
|
||||
|
||||
$js_script .= " var opsd_website_dns = jQuery(location).attr('hostname');"; // server.com
|
||||
$js_script .= " if ( opsd_email_from != opsd_website_dns ) {";
|
||||
$js_script .= " jQuery('#link_user_from').parent().append('<div class=\'updated\' style=\'border-left-color:#ffb900;padding:5px 10px;\'>". esc_js(__('Email different from website DNS, its can be a reason of not delivery emails. Please use the email withing the same domain as your website!', 'secure-downloads'))."</div>')";
|
||||
$js_script .= " }";
|
||||
|
||||
$js_script .= " }); ";
|
||||
|
||||
|
||||
|
||||
// Eneque JS to the footer of the page
|
||||
opsd_enqueue_js( $js_script );
|
||||
}
|
||||
|
||||
|
||||
// </editor-fold>
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Settings_Page_Email_LinkUser() , '__construct') ); // Executed after creation of Menu
|
||||
|
||||
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc=" Emails Sending After New item " >
|
||||
|
||||
/** Send email to customer with link for downloading file.
|
||||
*
|
||||
* @param array $replace - Array with replace parameters for email.
|
||||
* @param string $email_to - Email address
|
||||
* @param string $send_copy_to_admin - On|Off
|
||||
* @param array $other_params - Optional. Array of validated parameters from submit form at Send page
|
||||
* @return \OPSD_Emails_API_LinkUser|boolean
|
||||
*/
|
||||
function opsd_send_email_to_user_notification( $replace = array(), $email_to = '', $send_copy_to_admin = 'Off', $other_params = array() ) {
|
||||
|
||||
$is_continue = true;
|
||||
|
||||
$is_continue = apply_filters( 'opsd_send_email_to_user_notification_filter', $is_continue, $replace, $email_to, $send_copy_to_admin, $other_params);
|
||||
|
||||
if ( $is_continue !== true )
|
||||
return $is_continue;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Load Data
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Check if New Email Template Exist or NOT
|
||||
* Exist - return empty array in format: array( OPTION_NAME => array() )
|
||||
* Its will load DATA from DB, during creattion mail_api CLASS
|
||||
* during initial activation of the API its try to get option from DB
|
||||
* We need to define this API before checking POST, to know all available fields
|
||||
* Define Email Name & define field values from DB, if not exist, then default values.
|
||||
* Not Exist - import Old Data from DB
|
||||
* or get "default" data from settings and return array with this data
|
||||
* This data its initial parameters for definition fields in mail_api CLASS
|
||||
*
|
||||
*/
|
||||
|
||||
$init_fields_values = array();//opsd_import6_email__link_user__get_fields_array_for_activation();
|
||||
|
||||
// Get Value of first element - array of default or imported OLD data, because need only array of values without key - name of options for wp_options table
|
||||
//$init_fields_values = array_shift( array_values( $init_fields_values ) );
|
||||
|
||||
$mail_api = new OPSD_Emails_API_LinkUser( OPSD_EMAIL_LINK_USER_ID, $init_fields_values );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if ( $mail_api->fields_values['enabled'] == 'Off' ) return false; // Email template deactivated - exit.
|
||||
|
||||
add_filter( 'opsd_email_api_is_allow_send_copy' , 'opsd_email_api_is_allow_send_copy_block' , 10, 3);
|
||||
|
||||
|
||||
if ( ! empty( $replace['to'] ) )
|
||||
$valid_email = sanitize_email( $replace['to'] );
|
||||
|
||||
if ( ! empty( $email_to ) )
|
||||
$valid_email = sanitize_email( $email_to );
|
||||
|
||||
if ( empty( $valid_email ) ) return $mail_api; //return false;
|
||||
|
||||
if ( ! empty( $replace['to_name'] ) )
|
||||
$email_to_name = trim( wp_specialchars_decode( esc_html( stripslashes( $replace['to_name'] ) ), ENT_QUOTES ) );
|
||||
else
|
||||
$email_to_name = '';
|
||||
|
||||
$to = $email_to_name . ' <' . $valid_email . '> ';
|
||||
|
||||
$email_result = $mail_api->send( $to , $replace );
|
||||
|
||||
// Send copy of email to admin also to "From" email address
|
||||
if ( $send_copy_to_admin == 'On') {
|
||||
$subject = $mail_api->get_field_value('subject');
|
||||
$mail_api->set_field_value('subject', __('Email copy to', 'secure-downloads') . ': ' . $valid_email . ' ' . $subject );
|
||||
$email_result = $mail_api->send( $mail_api->get_from__email_address() , $replace );
|
||||
$mail_api->set_field_value('subject', $subject );
|
||||
}
|
||||
|
||||
//debuge( (int) $email_result, $to , $replace);
|
||||
|
||||
return $mail_api;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** Block Sending copy of email to Admin, based on OPSD_Emails_API interface, instead of that we will sent it manually from opsd_send_email_to_user_notification function
|
||||
*
|
||||
* @param boolean $is_send_email
|
||||
* @param type $id
|
||||
* @param type $fields_values
|
||||
* @return boolean
|
||||
*/
|
||||
function opsd_email_api_is_allow_send_copy_block( $is_send_email, $id, $fields_values ) {
|
||||
$is_send_email = false;
|
||||
return $is_send_email;
|
||||
}
|
||||
// </editor-fold>
|
||||
@@ -0,0 +1,276 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of Add New Item
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-10-31
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
/** Show Content
|
||||
* Update Content
|
||||
* Define Slug
|
||||
* Define where to show
|
||||
*/
|
||||
class OPSD_Page_Files extends OPSD_Page_Structure {
|
||||
|
||||
|
||||
public function in_page() {
|
||||
return 'opsd-files';
|
||||
}
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
$tabs[ 'add-files' ] = array(
|
||||
'title' => __('Add New', 'secure-downloads') // Title of TAB
|
||||
, 'hint' => __('Manage Files', 'secure-downloads') // Hint
|
||||
, 'page_title' => __('Manage Files', '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-plus' // 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()
|
||||
);
|
||||
|
||||
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.
|
||||
|
||||
// Submit /////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name = 'opsd_products_csv_form'; // Define form name
|
||||
$updated_data = '';
|
||||
if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { // Check if was clicked on Saved
|
||||
|
||||
// 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
|
||||
$updated_data = $this->update();
|
||||
$updated_data = $updated_data['original_validated_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 '<span class="wpdevelop">';
|
||||
opsd_js_for_items_page();
|
||||
echo '</span>';
|
||||
|
||||
|
||||
// Content ////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
<span class="metabox-holder">
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_products_csv', __('Files List', 'secure-downloads') ); ?>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr class="opsd_tr_opsd_products_csv_text " valign="top">
|
||||
<td scope="row" colspan="2">
|
||||
<?php
|
||||
|
||||
$field_name = 'opsd_products_csv_text';
|
||||
|
||||
$field_value = get_opsd_option('opsd_products_csv' );
|
||||
//$field_value = json_encode( $field_value ); // array('a' => 1, 'b' => 2 ... ) => {"a":1,"b":2 ...}
|
||||
|
||||
$place_holder = str_replace( '|', get_opsd_option( 'opsd_csv_separator' ), __( 'ID | Title | Version Number | Desciption | Path (URL)', 'secure-downloads' ) );
|
||||
$field = array(
|
||||
'title' => ''
|
||||
, 'description' => ''
|
||||
, 'type' => 'textarea'
|
||||
, 'value' => empty( $updated_data ) ? $field_value : $updated_data
|
||||
, 'class' => ''
|
||||
, 'css' => 'width:100%;'
|
||||
, 'placeholder' => $place_holder
|
||||
, 'disabled' => false
|
||||
, 'rows' => 8
|
||||
, 'show_in_2_cols' => true
|
||||
, 'only_field' => true
|
||||
);
|
||||
OPSD_Settings_API::field_textarea_row_static( $field_name, $field );
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="opsd_tr_opsd_products_csv_text " valign="top">
|
||||
<td scope="row" colspan="2" style="font-style: italic;">
|
||||
<?php
|
||||
echo __( 'Please use one product per line.', 'secure-downloads' ) . '<br/>';
|
||||
echo __( 'CSV product configuration structure', 'secure-downloads' ) . ': <b>' . $place_holder . '</b>' . '<br/>';
|
||||
echo sprintf( __( 'Or just use simple text at row (without separators %s) for definition section.', 'secure-downloads' ), '<strong>' . get_opsd_option( 'opsd_csv_separator' ) . '</strong>' ) . '<br/>';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<?php
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Add New Files button
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<span class='wpdevelop' style="margin-right:15px;">
|
||||
<a class="button button-secondary opsd_btn_upload"
|
||||
style="font-weight: 600;"
|
||||
<?php echo 'data-' . esc_attr( 'modal_title' ) . '="' . esc_attr( __( 'Choose files', 'secure-downloads' ) ) . '" '; ?>
|
||||
<?php echo 'data-' . esc_attr( 'btn_title' ) . '="' . esc_attr( __( 'Insert', 'secure-downloads' ) ) . '" '; ?>
|
||||
href="javascript:void(0)" title="<?php _e('Add New Product' , 'secure-downloads') ?>"
|
||||
><span style="opsd_text_hide_mobile0"><?php echo __('Add New' , 'secure-downloads') . ' ' . __( 'Files', 'secure-downloads' ); ?> </span><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></a>
|
||||
</span>
|
||||
<?php
|
||||
|
||||
// Get OPSD_Upload obj. instance
|
||||
$opsd_upload = opsd_upload();
|
||||
|
||||
$opsd_upload->set_upload_button( '.opsd_btn_upload' );
|
||||
|
||||
$opsd_upload->set_element_insert_url( '.opsd_file_urls' );
|
||||
|
||||
?><input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary opsd_submit_button" /><?php
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Help Notice
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
?><div class="clear"style="margin-top:25px;"></div><?php
|
||||
|
||||
$notice_id = 'opsd_upload_help_section';
|
||||
if ( ! opsd_section_is_dismissed( $notice_id ) ) {
|
||||
|
||||
?><div id="<?php echo $notice_id; ?>"
|
||||
class="opsd_system_notice opsd_is_dismissible opsd_is_hideable notice-warning opsd_internal_notice"
|
||||
data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_opsdnonce' ); ?>"
|
||||
data-user-id="<?php echo get_current_user_id(); ?>"
|
||||
><?php
|
||||
|
||||
opsd_x_dismiss_button();
|
||||
|
||||
$field_options = array();
|
||||
$field_options[] = '<strong>' . __( 'How to add new product ?', 'secure-downloads' ) . '</strong>';
|
||||
$field_options[] = '1. ' . sprintf( __( 'Click on %s"Add New"%s button and upload your files', 'secure-downloads' ), '<strong>', '</strong>' );
|
||||
$field_options[] = '2. ' . sprintf( __( 'Enter Title, Version Number and Description at %s"Attachment details"%s section', 'secure-downloads' ), '<strong>', '</strong>' ) . ' <em>(' . __( 'at right side of page', 'secure-downloads' ) . ')</em>';
|
||||
$field_options[] = '3. ' . sprintf( __( 'Select one or multiple files and click on insert button', 'secure-downloads' ) );
|
||||
$field_options[] = '4. ' . sprintf( __( 'Save the changes.', 'secure-downloads' ) );
|
||||
|
||||
OPSD_Settings_API::field_help_row_static(
|
||||
'help_translation_section_after_legend_items'
|
||||
, array(
|
||||
'type' => 'help'
|
||||
, 'value' => $field_options
|
||||
, 'class' => ''
|
||||
, 'css' => 'margin:0;padding:0;border:0;'
|
||||
, 'description' => ''
|
||||
, 'cols' => 2
|
||||
, 'group' => 'help'
|
||||
, 'tr_class' => ''
|
||||
, 'description_tag' => 'p'
|
||||
)
|
||||
);
|
||||
?></div><?php
|
||||
}
|
||||
|
||||
?>
|
||||
</form>
|
||||
</span>
|
||||
<?php
|
||||
do_action( 'opsd_hook_settings_page_footer', 'csv_products' );
|
||||
}
|
||||
|
||||
|
||||
/** Save Settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function update() {
|
||||
|
||||
$validated_option = OPSD_Settings_API::validate_text_post_static( 'opsd_products_csv_text' );
|
||||
|
||||
update_opsd_option('opsd_products_csv', $validated_option );
|
||||
|
||||
opsd_show_changes_saved_message();
|
||||
|
||||
return array ( 'original_validated_data' => $validated_option );
|
||||
|
||||
|
||||
/** Standard Saving || Actions
|
||||
*
|
||||
$post_action_key = 'opsd_action';
|
||||
|
||||
$post_key = 'opsd_products_csv_text';
|
||||
|
||||
if ( isset( $_POST[ $post_action_key ] ) && ( $_POST[ $post_action_key ] == 'gogo2list' ) && ( isset( $_POST[ $post_key ] ) ) ) {
|
||||
|
||||
// Get Validated post
|
||||
$gogo_validated = OPSD_Settings_API::validate_text_post_static( $post_key );
|
||||
|
||||
|
||||
$show_debug_info_validated = OPSD_Settings_API::validate_checkbox_post_static( 'show_debug_info' );
|
||||
if ($show_debug_info_validated == 'On'){
|
||||
debuge( 'POST', $_POST );
|
||||
debuge('Validated data', $gogo_validated );
|
||||
}
|
||||
|
||||
|
||||
update_opsd_option('opsd_products_csv', $gogo_validated ); // Save to DB
|
||||
|
||||
opsd_show_changes_saved_message();
|
||||
|
||||
// opsd_show_message ( __('Done', 'secure-downloads'), 0 ); // Show Message
|
||||
|
||||
return array ( 'original_validated_data' => $gogo_validated ); // Exit, for do not parse
|
||||
}
|
||||
*/
|
||||
|
||||
/** Standard Bulk Saving of settings
|
||||
$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.
|
||||
|
||||
unset($validated_fields['opsd_start_day_weeek']); // Skip saving specific option, for example in Demo mode.
|
||||
|
||||
$this->settings_api()->save_to_db( $validated_fields ); // Save fields to DB
|
||||
//opsd_show_changes_saved_message();
|
||||
opsd_show_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') );
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_Files() , '__construct') ); // Executed after creation of Menu
|
||||
@@ -0,0 +1,479 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of Add New Item
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-10-31
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
|
||||
/** Show Content
|
||||
* Update Content
|
||||
* Define Slug
|
||||
* Define where to show
|
||||
*/
|
||||
class OPSD_Page_FilesSortable extends OPSD_Page_Structure {
|
||||
|
||||
|
||||
public function in_page() {
|
||||
return 'opsd-files';
|
||||
}
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
$tabs[ 'files-sortable' ] = array(
|
||||
'title' => __('Sortable List', 'secure-downloads') // Title of TAB
|
||||
, 'hint' => __('Sortable List', 'secure-downloads') // Hint
|
||||
, 'page_title' => __('Manage List', '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-sort' // 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()
|
||||
);
|
||||
|
||||
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.
|
||||
|
||||
// Submit /////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name = 'opsd_sortable_products_form'; // Define form name
|
||||
$updated_data = '';
|
||||
if ( isset( $_POST['is_form_sbmitted_'. $submit_form_name ] ) ) { // Check if was clicked on Saved
|
||||
|
||||
// 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
|
||||
$updated_data = $this->update();
|
||||
//$updated_data = $updated_data['original_validated_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 '<span class="wpdevelop">';
|
||||
opsd_js_for_items_page();
|
||||
echo '</span>';
|
||||
|
||||
|
||||
// Content ////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
<span class="metabox-holder">
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_sortable_products_list', __('Products List', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->show_soratble_table(); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<div class="clear"></div>
|
||||
<input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary opsd_submit_button" />
|
||||
|
||||
</form>
|
||||
</span>
|
||||
<?php
|
||||
do_action( 'opsd_hook_settings_page_footer', 'sortable_products' );
|
||||
}
|
||||
|
||||
|
||||
/** Save Settings
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function update() {
|
||||
|
||||
//debuge($_POST);
|
||||
|
||||
if ( isset( $_POST['pro'] ) ) {
|
||||
|
||||
// Get Exist List of products ////////////////////////////////////
|
||||
$products_csv = get_opsd_option('opsd_products_csv' );
|
||||
|
||||
$products_obj = new OPSD_Products();
|
||||
|
||||
$products_obj->define_products_from_csv( $products_csv );
|
||||
|
||||
$products = $products_obj->get_products(); /**
|
||||
[id] => 206
|
||||
[title] => product.developer
|
||||
[version_num] => 'gdfgd'
|
||||
[description] => 'gdfgdf'
|
||||
[path] => /wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04/product.developer.zip
|
||||
*/
|
||||
|
||||
// New products /////////////////////////////////////////////////
|
||||
$new_products_arr = array();
|
||||
//debuge($_POST);
|
||||
foreach ( $_POST['pro'] as $post_index => $pro_id ) {
|
||||
|
||||
$product_arr = array();
|
||||
|
||||
$exist_product = $products_obj->get_product( $pro_id );
|
||||
//debuge($pro_id, $exist_product) ;
|
||||
if ( ! empty( $exist_product ) ) {
|
||||
|
||||
$post_key = 'pro'; // ID
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'id' ] = OPSD_Settings_API::validate_text_post_static( $post_key , $post_index ); // Validate
|
||||
}
|
||||
$post_key = 'pro_title';
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'title' ] = OPSD_Settings_API::validate_text_post_static( $post_key , $post_index ); // Validate
|
||||
}
|
||||
$post_key = 'pro_version_num';
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'version_num' ] = OPSD_Settings_API::validate_text_post_static( $post_key , $post_index ); // Validate
|
||||
}
|
||||
|
||||
$post_key = 'pro_description';
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'description' ] = OPSD_Settings_API::validate_text_post_static( $post_key , $post_index ); // Validate
|
||||
}
|
||||
|
||||
//$product_arr[ 'description' ] = $exist_product['description'];
|
||||
|
||||
$post_key = 'pro_path';
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'path' ] = trim( str_replace(
|
||||
site_url()
|
||||
, ''
|
||||
, OPSD_Settings_API::validate_text_post_static( $post_key , $post_index )
|
||||
) ); // Get local relative path
|
||||
}
|
||||
} else {
|
||||
|
||||
// Product does not exist so probabaly its Group section title.
|
||||
$post_key = 'pro_title';
|
||||
if ( isset( $_POST[ $post_key ] ) && isset( $_POST[ $post_key ][ $post_index ] ) ) {
|
||||
$product_arr[ 'title' ] = OPSD_Settings_API::validate_text_post_static( $post_key , $post_index ); // Validate
|
||||
}
|
||||
|
||||
}
|
||||
$new_products_arr[] = $product_arr;
|
||||
}
|
||||
|
||||
// Create CSV
|
||||
//debuge($new_products_arr);
|
||||
$products_csv = $products_obj->save_products( $new_products_arr );
|
||||
opsd_show_changes_saved_message();
|
||||
|
||||
return array ( 'original_validated_data' => $products_csv );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// $validated_option = OPSD_Settings_API::validate_text_post_static( 'opsd_sortable_products_text' );
|
||||
//
|
||||
// update_opsd_option('opsd_sortable_products', $validated_option );
|
||||
//
|
||||
// opsd_show_changes_saved_message();
|
||||
//
|
||||
// return array ( 'original_validated_data' => $validated_option );
|
||||
|
||||
|
||||
/** Standard Saving || Actions
|
||||
*
|
||||
$post_action_key = 'opsd_action';
|
||||
|
||||
$post_key = 'opsd_sortable_products_text';
|
||||
|
||||
if ( isset( $_POST[ $post_action_key ] ) && ( $_POST[ $post_action_key ] == 'gogo2list' ) && ( isset( $_POST[ $post_key ] ) ) ) {
|
||||
|
||||
// Get Validated post
|
||||
$gogo_validated = OPSD_Settings_API::validate_text_post_static( $post_key );
|
||||
|
||||
|
||||
$show_debug_info_validated = OPSD_Settings_API::validate_checkbox_post_static( 'show_debug_info' );
|
||||
if ($show_debug_info_validated == 'On'){
|
||||
debuge( 'POST', $_POST );
|
||||
debuge('Validated data', $gogo_validated );
|
||||
}
|
||||
|
||||
|
||||
update_opsd_option('opsd_sortable_products', $gogo_validated ); // Save to DB
|
||||
|
||||
opsd_show_changes_saved_message();
|
||||
|
||||
// opsd_show_message ( __('Done', 'secure-downloads'), 0 ); // Show Message
|
||||
|
||||
return array ( 'original_validated_data' => $gogo_validated ); // Exit, for do not parse
|
||||
}
|
||||
*/
|
||||
|
||||
/** Standard Bulk Saving of settings
|
||||
$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.
|
||||
|
||||
unset($validated_fields['opsd_start_day_weeek']); // Skip saving specific option, for example in Demo mode.
|
||||
|
||||
$this->settings_api()->save_to_db( $validated_fields ); // Save fields to DB
|
||||
//opsd_show_changes_saved_message();
|
||||
opsd_show_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') );
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public function show_soratble_table() {
|
||||
|
||||
// Get List of products ////////////////////////////////////
|
||||
$products_csv = get_opsd_option('opsd_products_csv' );
|
||||
|
||||
$products_obj = new OPSD_Products();
|
||||
|
||||
$products_obj->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();
|
||||
|
||||
//debuge($products);die;
|
||||
/**
|
||||
[id] => 207
|
||||
[order] => 0
|
||||
[ip] => 0.0.0.0
|
||||
[expire] => +1 day
|
||||
[title] => product.multisite
|
||||
[version_num] =>
|
||||
[description] =>
|
||||
[path] => /wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04/product.multisite.zip
|
||||
*/
|
||||
?>
|
||||
<div class="opsd_sortable_table wpdevelop" >
|
||||
<table class="widefat opsd_input_table sortable table table-striped" cellspacing="0" cellpadding="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="sort"> </th>
|
||||
<th style="width:30px;"><?php _e('ID', 'secure-downloads' ) ?></th>
|
||||
<th style="width:15%"><?php _e('Title', 'secure-downloads' ) ?></th>
|
||||
<th style="width:10%"><?php _e('Version', 'secure-downloads' ) ?></th>
|
||||
<th style="width:22%"><?php _e('Desciption', 'secure-downloads' ) ?></th>
|
||||
<th><?php _e('Path', 'secure-downloads' ) ?></th>
|
||||
<th style="width:70px;"><?php _e('Actions', 'secure-downloads' ) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="accounts">
|
||||
<?php
|
||||
$i = -1;
|
||||
if ( ! empty( $products ) ) {
|
||||
|
||||
foreach ( $products as $product_id => $product ) {
|
||||
$i++;
|
||||
|
||||
if ( count($product) > 5 ) { //Skip emty rows.
|
||||
|
||||
$product_id = $product[ 'id' ];
|
||||
echo
|
||||
'<tr class="account" id="'. $product_id .'">'
|
||||
. '<td class="sort"><input type="hidden" value="' . esc_attr( wp_unslash( $product_id ) ) . '" name="pro[' . $i . ']" /></td>'
|
||||
. '<th style="vertical-align:middle;">' . wp_unslash( esc_js( $product_id ) ) . '</th>'
|
||||
. '<td><input style="font-weight:600;" type="text" value="' . wp_unslash( esc_js( $product['title'] ) ) . '" name="pro_title[' . $i . ']" /></td>'
|
||||
. '<td><input type="text" value="' . wp_unslash( esc_js( $product['version_num'] ) ) . '" name="pro_version_num[' . $i . ']" /></td>'
|
||||
. '<td><textarea name="pro_description[' . $i . ']" style="height:2em;width:100%;">'.wp_unslash( esc_js( $product['description'] ) ).'</textarea></td>'
|
||||
. '<td><input type="text" value="' . wp_unslash( esc_js( $product['path'] ) ) . '" name="pro_path[' . $i . ']" /></td>'
|
||||
. '<td style="text-align:center;">'
|
||||
. '<a href="javascript:void(0)"
|
||||
class="button-secondary button opsd_delete_row"
|
||||
title="'. esc_js( __( 'Delete', 'secure-downloads' ) ) .'"
|
||||
data-original-title="Completely "><i class="glyphicon glyphicon-remove"></i></a>'
|
||||
.'</td>'
|
||||
. '</tr>';
|
||||
} else {
|
||||
|
||||
$product_id = time() + wp_rand( 1000 );
|
||||
echo '<tr class="account" id="'. $product_id .'">'
|
||||
. '<td class="sort"><input type="hidden" value="' . esc_attr( wp_unslash( $product_id ) ) . '" name="pro[' . $i . ']" /></td>'
|
||||
. '<td style="vertical-align:middle;" colspan="5">'
|
||||
. '<input style="font-weight:600;" type="text" value="' . wp_unslash( esc_js( $product['title'] ) ) . '" name="pro_title[' . $i . ']" />'
|
||||
. '</td>'
|
||||
. '<td style="text-align:center;">'
|
||||
. '<a href="javascript:void(0)"
|
||||
class="button-secondary button opsd_delete_row"
|
||||
title="'. esc_js( __( 'Delete', 'secure-downloads' ) ) .'"
|
||||
data-original-title="Completely "><i class="glyphicon glyphicon-remove"></i></a>'
|
||||
.'</td>'
|
||||
. '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<?php /* ?>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="7"><a href="#" class="add button"><?php _e( '+ Add Account' , 'secure-downloads' ); ?></a> <a href="#" class="remove_rows button"><?php _e( 'Remove selected account(s)' , 'secure-downloads' ); ?></a></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<?php /**/ ?>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
|
||||
jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
|
||||
|
||||
|
||||
$('.opsd_input_table tbody th, .opsd_sortable_table tbody td').css('cursor','move');
|
||||
|
||||
$('.opsd_input_table tbody td.sort').css('cursor','move');
|
||||
|
||||
$('.opsd_input_table.sortable tbody').sortable({
|
||||
items:'tr',
|
||||
cursor:'move',
|
||||
axis:'y',
|
||||
scrollSensitivity:40,
|
||||
forcePlaceholderSize: true,
|
||||
helper: 'clone',
|
||||
opacity: 0.65,
|
||||
placeholder: '.opsd_sortable_table .sort',
|
||||
start:function(event,ui){
|
||||
ui.item.css('background-color','#f6f6f6');
|
||||
},
|
||||
stop:function(event,ui){
|
||||
ui.item.removeAttr('style');
|
||||
}
|
||||
});
|
||||
|
||||
jQuery( '.opsd_sortable_table' ).on( 'click', '.opsd_delete_row', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded
|
||||
|
||||
var jq_row = jQuery( this ).closest( 'tr' );
|
||||
|
||||
jq_row.remove();
|
||||
});
|
||||
|
||||
|
||||
jQuery( '.opsd_sortable_table' ).on( 'focusin', 'textarea[name^="pro_description"]', function(){ jQuery( this ).css( 'height', '5em' ); } );
|
||||
jQuery( '.opsd_sortable_table' ).on( 'focusout', 'textarea[name^="pro_description"]', function(){ jQuery( this ).css( 'height', '2em' ); } );
|
||||
|
||||
//jQuery( 'input[name^="pro_path"]' ).on( 'focus', function(){ jQuery( this ).css( 'height', '5em' ); } );
|
||||
//jQuery( 'input[name^="pro_path"]' ).on( 'blur', function(){ jQuery( this ).css( 'height', 'auto' ); } );
|
||||
/** Add new row
|
||||
jQuery('.opsd_sortable_table').on( 'click', 'a.add', function(){
|
||||
|
||||
var size = jQuery('.opsd_sortable_table tbody .account').size();
|
||||
|
||||
jQuery('<tr class="account">\
|
||||
<td class="sort"></td>\
|
||||
<td><legend class="opsd_mobile_legend"><?php echo esc_js( '' ); ?>:</legend><input type="text" name="bank_transfer_account_name[' + size + ']" /></td>\
|
||||
<td><legend class="opsd_mobile_legend"><?php echo esc_js( '' ); ?>:</legend><input type="text" name="bank_transfer_account_number[' + size + ']" /></td>\
|
||||
<td><legend class="opsd_mobile_legend"><?php echo esc_js( '' ); ?>:</legend><input type="text" name="bank_transfer_bank_name[' + size + ']" /></td>\
|
||||
<td><legend class="opsd_mobile_legend"><?php echo esc_js( '' ); ?>:</legend><input type="text" name="bank_transfer_sort_code[' + size + ']" /></td>\
|
||||
</tr>').appendTo('.opsd_sortable_table table tbody');
|
||||
|
||||
jQuery('.opsd_input_table tbody th, .opsd_sortable_table tbody td').css('cursor','move');
|
||||
return false;
|
||||
});
|
||||
*/
|
||||
|
||||
/** Delete current row depend from Focus
|
||||
$('.opsd_input_table .remove_rows').on( 'click', function() {
|
||||
var $tbody = $(this).closest('.opsd_input_table').find('tbody');
|
||||
if ( $tbody.find('tr.current').size() > 0 ) {
|
||||
$current = $tbody.find('tr.current');
|
||||
|
||||
$current.each(function(){
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
var controlled = false;
|
||||
var shifted = false;
|
||||
var hasFocus = false;
|
||||
|
||||
$(document).on( 'keyup keydown', function(e){ shifted = e.shiftKey; controlled = e.ctrlKey || e.metaKey } );
|
||||
|
||||
$('.opsd_input_table').on( 'focus click', 'input', function( e ) {
|
||||
|
||||
$this_table = $(this).closest('table');
|
||||
$this_row = $(this).closest('tr');
|
||||
|
||||
if ( ( e.type == 'focus' && hasFocus != $this_row.index() ) || ( e.type == 'click' && $(this).is(':focus') ) ) {
|
||||
|
||||
hasFocus = $this_row.index();
|
||||
|
||||
if ( ! shifted && ! controlled ) {
|
||||
$('tr', $this_table).removeClass('current').removeClass('last_selected');
|
||||
$this_row.addClass('current').addClass('last_selected');
|
||||
} else if ( shifted ) {
|
||||
$('tr', $this_table).removeClass('current');
|
||||
$this_row.addClass('selected_now').addClass('current');
|
||||
|
||||
if ( $('tr.last_selected', $this_table).size() > 0 ) {
|
||||
if ( $this_row.index() > $('tr.last_selected, $this_table').index() ) {
|
||||
$('tr', $this_table).slice( $('tr.last_selected', $this_table).index(), $this_row.index() ).addClass('current');
|
||||
} else {
|
||||
$('tr', $this_table).slice( $this_row.index(), $('tr.last_selected', $this_table).index() + 1 ).addClass('current');
|
||||
}
|
||||
}
|
||||
|
||||
$('tr', $this_table).removeClass('last_selected');
|
||||
$this_row.addClass('last_selected');
|
||||
} else {
|
||||
$('tr', $this_table).removeClass('last_selected');
|
||||
if ( controlled && $(this).closest('tr').is('.current') ) {
|
||||
$this_row.removeClass('current');
|
||||
} else {
|
||||
$this_row.addClass('current').addClass('last_selected');
|
||||
}
|
||||
}
|
||||
|
||||
$('tr', $this_table).removeClass('selected_now');
|
||||
|
||||
}
|
||||
}).on( 'blur', 'input', function( e ) {
|
||||
hasFocus = false;
|
||||
});
|
||||
*/
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_FilesSortable() , '__construct') ); // Executed after creation of Menu
|
||||
987
wp-content/plugins/secure-downloads/core/admin/page-send.php
Normal file
987
wp-content/plugins/secure-downloads/core/admin/page-send.php
Normal file
@@ -0,0 +1,987 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of item Listing page
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-11-13
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
/** Show Content
|
||||
* Update Content
|
||||
* Define Slug
|
||||
* Define where to show
|
||||
*/
|
||||
class OPSD_Page_Single extends OPSD_Page_Structure {
|
||||
|
||||
|
||||
public function in_page() {
|
||||
return 'opsd';
|
||||
}
|
||||
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
$tabs[ 'send' ] = array(
|
||||
'title' => __('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 '<span class="wpdevelop">';
|
||||
opsd_js_for_items_page();
|
||||
echo '</span>';
|
||||
|
||||
?><span class="wpdevelop"><?php // BS UI CSS Class
|
||||
// T o o l b a r s /////////////////////////////////////////////////
|
||||
// opsd_items_toolbar();
|
||||
?></span><?php
|
||||
|
||||
?><div class="clear" style="height:0px;"></div><?php
|
||||
|
||||
|
||||
// Content ////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
<span class="metabox-holder">
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post" >
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
<div class="clear" style="margin-bottom:0px;"></div>
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_left" >
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_single_results', __('Send', 'secure-downloads') ); ?>
|
||||
|
||||
<?php
|
||||
|
||||
// Get List of products ////////////////////////////////////
|
||||
$products_csv = get_opsd_option('opsd_products_csv' );
|
||||
|
||||
$products_obj = new OPSD_Products();
|
||||
|
||||
$products_obj->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 ) ) {
|
||||
|
||||
?><div id="<?php echo $notice_id; ?>"
|
||||
class="opsd_system_notice opsd_is_dismissible0 opsd_is_hideable0 notice-error opsd_internal_notice"
|
||||
data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_opsdnonce' ); ?>"
|
||||
data-user-id="<?php echo get_current_user_id(); ?>"
|
||||
><?php
|
||||
// opsd_x_dismiss_button();
|
||||
echo '<strong>' . __( 'Warning!', 'secure-downloads' ) . '</strong> ';
|
||||
printf( __( 'No products defined at %s menu page.', 'secure-downloads' )
|
||||
, '<a href="' . admin_url( 'admin.php?page=opsd-files' ) . '">'
|
||||
. '<strong>' . 'Secure Downloads > ' . __( 'Files', 'secure-downloads' ) . '</strong>'
|
||||
. '</a>'
|
||||
);
|
||||
?></div><?php
|
||||
}
|
||||
|
||||
$opsd_csv_separator = get_opsd_option( 'opsd_csv_separator' );
|
||||
if ( ( strlen( $products_csv ) > 0 )
|
||||
&& ( strpos( $products_csv, $opsd_csv_separator ) === false ) ) {
|
||||
|
||||
|
||||
$notice_id = 'opsd_warning_wrong_csv_separator';
|
||||
if ( ! opsd_section_is_dismissed( $notice_id ) ) {
|
||||
|
||||
?><div id="<?php echo $notice_id; ?>"
|
||||
class="opsd_system_notice opsd_is_dismissible0 opsd_is_hideable0 notice-warning opsd_internal_notice"
|
||||
data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_opsdnonce' ); ?>"
|
||||
data-user-id="<?php echo get_current_user_id(); ?>"
|
||||
><?php
|
||||
// opsd_x_dismiss_button();
|
||||
echo '<strong>' . __( 'Warning!', 'secure-downloads' ) . '</strong> ';
|
||||
printf( __( 'Probabaly you have defined incorrect CSV separator at %s menu page.', 'secure-downloads' )
|
||||
, '<a href="' . admin_url( 'admin.php?page=opsd-settings' ) . '#opsd_general_settings_opsd_misc_metabox">'
|
||||
. '<strong>' . __( 'Settings', 'secure-downloads' ) . '</strong>'
|
||||
. '</a>'
|
||||
);
|
||||
?></div><?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if ( ! empty( $data_after_update ) ) {
|
||||
opsd_show_copy_button();
|
||||
}
|
||||
|
||||
?><div class="opsd_link_container wpdevelop"><?php
|
||||
|
||||
// Email //////////////////////////////////////////////////
|
||||
$fields = array( 'type' => 'email',
|
||||
'title' => ''
|
||||
, 'disabled' => false
|
||||
, 'class' => ''
|
||||
, 'css' => ''
|
||||
, 'placeholder' => 'info@server.com'
|
||||
, 'description' => ''
|
||||
, 'attr' => array()
|
||||
, 'group' => 'general'
|
||||
, 'tr_class' => ''
|
||||
, 'only_field' => true
|
||||
, 'description_tag' => 'p'
|
||||
, 'validate_as' => array( 'email' )
|
||||
, 'value' => ( ( ! empty( $_GET[ 'email' ] ) ) ? sanitize_email( $_GET[ 'email' ] ) : '' ) //FixIn: 1.1.5
|
||||
);
|
||||
OPSD_Settings_API::field_text_row_static( 'opsd_email_to', $fields );
|
||||
|
||||
// Send Button ////////////////////////////////////////////
|
||||
?>
|
||||
<a class="button button-primary opsd_send_button opsd_generate_button"
|
||||
href="javascript:void(0)" title="<?php _e('Generate Secure Link for Download' , 'secure-downloads') ?>"
|
||||
><span class="opsd_text_hide_mobile"><?php _e('Generate' , 'secure-downloads') ?> </span><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
<input type="hidden" value='' name='opsd_action' id='opsd_action' />
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
// Products List //////////////////////////////////////////
|
||||
$options = array( '' => __( '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' );
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_single_help', __('Info', 'secure-downloads') ); ?>
|
||||
|
||||
<?php //$this->settings_api()->show( 'help' ); ?>
|
||||
<div class="opsd_submmary">
|
||||
<?php printf(__('Nothing yet.', 'secure-downloads'),'<code>[email]</code>') ?>
|
||||
</div>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
</div>
|
||||
<div class="opsd_settings_row opsd_settings_row_right">
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_single_actions', __('Advanced', 'secure-downloads') ); ?>
|
||||
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="padding-left: 0;">
|
||||
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
||||
$mail_api = new OPSD_Emails_API_LinkUser( OPSD_EMAIL_LINK_USER_ID );
|
||||
|
||||
$field_name = 'send_copy_to_admin';
|
||||
|
||||
$field = array(
|
||||
'title' => ''
|
||||
, '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 );
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
$options = array(
|
||||
'' => __('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 );
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<!-- <input type="button" value="<?php _e('Send', 'secure-downloads'); ?>" class="button button-primary opsd_send_button" /> -->
|
||||
<!-- <input type="submit" value="<?php _e('Submit', 'secure-downloads'); ?>" class="button button-primary opsd_submit_button" />-->
|
||||
|
||||
</form>
|
||||
<?php
|
||||
|
||||
if ( ! empty( $data_after_update ) )
|
||||
echo $data_after_update['sent_summary_content'];
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
|
||||
opsd_show_opsd_footer();
|
||||
|
||||
$this->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
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
setTimeout(function() { document.location.href = "<?php echo opsd_get_master_url(); ?>"; }, 30000);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
return array ( 'validated_data' => $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, '<body' );
|
||||
if ( $pos !== false ) {
|
||||
$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);
|
||||
?><table class="form-table"><tbody><?php
|
||||
|
||||
?><tr><td colspan="2" style="padding-left: 0;font-size: 1.2em;border-bottom: 2px dashed #ddd;line-height: 1.8em;"><?php
|
||||
if ( ! empty ( $validated['opsd_email_to'] ) )
|
||||
echo __( 'Email have sent to', 'secure-downloads' ) . ' <strong>' . $validated['opsd_email_to'] . '</strong> - ';
|
||||
//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'] . ' <code>' . $replace['product_expire_date'] . '</code>';
|
||||
?></td></tr><?php
|
||||
|
||||
// Link
|
||||
$fields = array(
|
||||
'title' => __( '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 );
|
||||
|
||||
?></tbody></table><?php
|
||||
|
||||
opsd_close_meta_box_section();
|
||||
/*
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery( document ).ready(function(){
|
||||
setTimeout(function() {
|
||||
opsd_scroll_to( '#opsd_sent_summary_metabox' );
|
||||
}, 100)
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
*/
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function js() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
// Catch data for summary
|
||||
jQuery('#opsd_email_to').on( "keypress", function( event ) {
|
||||
if( event.which != 13) {
|
||||
opsd_generate_send_info();
|
||||
//return false;
|
||||
}
|
||||
});
|
||||
jQuery('#opsd_email_to,#opsd_product_selection,#opsd_product_expire,#opsd_product_ip_lock').on( 'change', function(){
|
||||
opsd_generate_send_info();
|
||||
} );
|
||||
jQuery(document).ready( function(){
|
||||
setTimeout( opsd_generate_send_info , 1000);
|
||||
// opsd_generate_send_info();
|
||||
});
|
||||
// On click submit form
|
||||
jQuery( '.opsd_send_button' ).on( 'click', function() {
|
||||
if ( jQuery( '.opsd_send_button' ).hasClass( 'disabled' ) ) {
|
||||
return false; // Prevent submit form, if button disabled.
|
||||
}
|
||||
jQuery('#opsd_action').val('go_send');
|
||||
jQuery('#opsd_send_links_form<?php //echo $submit_form_name; ?>').trigger( 'submit' );
|
||||
return false;
|
||||
});
|
||||
//Allow enter key on textareas and submit buttons only
|
||||
jQuery(document).on( "keypress", ":input:not(textarea):not([type=submit])", function( event ) {
|
||||
if( event.which == 13) {
|
||||
if ( jQuery( '.opsd_send_button' ).hasClass( 'disabled' ) ) {
|
||||
return false; // Prevent submit form, if button disabled.
|
||||
}
|
||||
//alert('You pressed enter!');
|
||||
jQuery('#opsd_action').val('go_send');
|
||||
jQuery('#opsd_send_links_form<?php //echo $submit_form_name; ?>').trigger( 'submit' );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function opsd_generate_send_info() {
|
||||
|
||||
if ( jQuery( '#opsd_email_to' ).length == 0 )
|
||||
return;
|
||||
|
||||
var selected_products = [];
|
||||
var selected_products_val = [];
|
||||
jQuery('#opsd_product_selection :selected').each(function(i, selected){
|
||||
selected_products[i] = jQuery(selected).text().trim();
|
||||
selected_products_val[i] = jQuery(selected).val().trim();
|
||||
});
|
||||
selected_products = selected_products.join( ', ' );
|
||||
selected_products_val = selected_products_val.join( ', ' );
|
||||
if ( '' == selected_products_val ) {
|
||||
jQuery( '.opsd_send_button' ).addClass( 'disabled' );
|
||||
} else {
|
||||
jQuery( '.opsd_send_button' ).removeClass( 'disabled' )
|
||||
}
|
||||
|
||||
jQuery('.opsd_submmary').html('<table class="form-table"><tbody></tbody></table>');
|
||||
|
||||
if ( jQuery( '#opsd_email_to' ).val().trim() != '' ) {
|
||||
jQuery( '.opsd_send_button .opsd_text_hide_mobile' ).html('<?php echo esc_js( __( 'Send', 'secure-downloads' ) ); ?> ');
|
||||
jQuery('.opsd_submmary .form-table tbody').append( '<tr><th style="width:5em;"><?php echo esc_js( __( 'To', 'secure-downloads' ) ); ?></th><td>[' + jQuery( '#opsd_email_to' ).val().trim() + ']</td></tr>' );
|
||||
} else {
|
||||
jQuery( '.opsd_send_button .opsd_text_hide_mobile' ).html('<?php echo esc_js( __( 'Generate', 'secure-downloads' ) ); ?> ');
|
||||
jQuery('.opsd_submmary .form-table tbody').append( '<tr><th colspan="2" style=""><?php echo esc_js( __( 'Generate Secure Link for Download', 'secure-downloads' ) ); ?></th></tr>' );
|
||||
}
|
||||
|
||||
jQuery('.opsd_submmary .form-table tbody').append( '<tr><th style="width:5em;"><?php echo esc_js( __( 'Products', 'secure-downloads' ) ); ?></th><td>[' + selected_products.trim() + ']</td></tr>' );
|
||||
jQuery('.opsd_submmary .form-table tbody').append( '<tr><th style="width:5em;"><?php echo esc_js( __( 'Expire', 'secure-downloads' ) ); ?></th><td>[' + jQuery('#opsd_product_expire :selected').text().trim() + ']</td></tr>' );
|
||||
if ( jQuery('#opsd_product_ip_lock').val().trim() != '' )
|
||||
jQuery('.opsd_submmary .form-table tbody').append( '<tr><th style="width:5em;"><?php echo esc_js( __( 'IP Loc', 'secure-downloads' ) ); ?></th><td>' + jQuery('#opsd_product_ip_lock').val().trim() + '</td></tr>' );
|
||||
|
||||
jQuery( ".opsd_submmary" ).trigger( "generate_send_info" , [] ); // Action hook
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
public function css() {
|
||||
?>
|
||||
<style type="text/css">
|
||||
.opsd_link_container {
|
||||
display: flex;
|
||||
flex-flow: row nowrap;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.opsd_link_container #opsd_email_to {
|
||||
flex: 65% 1 0;
|
||||
font-size: 1.4em;
|
||||
font-weight: 600;
|
||||
height: 43px;
|
||||
line-height: 2;
|
||||
/*max-width: 25rem;*/
|
||||
min-width: 0;
|
||||
padding: 6px 10px;
|
||||
}
|
||||
.opsd_link_container .opsd_generate_button{
|
||||
flex: 10% 0 0;
|
||||
margin: 0 0 0 1.5em;
|
||||
line-height: 34px;
|
||||
font-size: 1.2em;
|
||||
text-align: center;
|
||||
height: 43px;
|
||||
padding: 5px 20px;
|
||||
box-shadow: none;
|
||||
}
|
||||
.opsd_tr_more_margin th,
|
||||
.opsd_tr_more_margin td {
|
||||
padding-top: 30px !important;
|
||||
}
|
||||
.metabox-holder select option{
|
||||
padding:0.7em 20px;
|
||||
height:1.5em;
|
||||
border-bottom:1px solid #ccc;
|
||||
}
|
||||
select.opsd_product_selection,
|
||||
#select_opsd_form {
|
||||
margin: 30px 0 0;
|
||||
width:100%;
|
||||
|
||||
max-width: 100%;
|
||||
height: 2.2em;
|
||||
/*line-height: 2.2em;*/
|
||||
font-size: 1.2em;
|
||||
}
|
||||
/*#opsd_email_to { */
|
||||
/* width: 75%;*/
|
||||
/* font-size: 1.4em;*/
|
||||
/* font-weight: 600;*/
|
||||
/* height: 2.1em; */
|
||||
/*}*/
|
||||
/*.opsd_page .opsd_send_button { */
|
||||
/* font-size: 1.4em;*/
|
||||
/* height: 2.04em;*/
|
||||
/* font-weight: 600;*/
|
||||
/* line-height: 1.91em;*/
|
||||
/* width: 100%;*/
|
||||
/* overflow: hidden;*/
|
||||
/* text-align: center;*/
|
||||
/* padding:0;*/
|
||||
/*}*/
|
||||
/* iPad mini and all iPhones and other Mobile Devices */
|
||||
@media (max-width: 782px) {
|
||||
.opsd_page .opsd_copy_2_clipboard_button,
|
||||
.opsd_page .opsd_send_button {
|
||||
line-height: 2.15;
|
||||
/* padding: 2px; */
|
||||
/* margin-top: 1px;*/
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_Single() , '__construct') ); // Executed after creation of Menu
|
||||
|
||||
|
||||
|
||||
|
||||
//function opsd_gotopages() {
|
||||
//
|
||||
// wp_redirect( admin_url('admin.php?page=opsd' ) );
|
||||
//}
|
||||
//add_action('wp_dashboard_setup', 'opsd_gotopages');
|
||||
|
||||
|
||||
function opsd_show_copy_button(){
|
||||
|
||||
if (
|
||||
( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], '/email-reminders/www' ) !== false ) )
|
||||
|| ( ( isset( $_SERVER['SCRIPT_FILENAME'] ) ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'wpbookingcalendar.com' ) !== false ) )
|
||||
|| ( ( isset( $_SERVER['HTTP_HOST'] ) ) && ( strpos( $_SERVER['HTTP_HOST'], 'wpbookingcalendar.com' ) !== false ) )
|
||||
){
|
||||
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
<div class="opsd_link_container wpdevelop" style="margin: 0 0 2em;justify-content: flex-end;">
|
||||
<a class="button button-primary opsd_copy_2_clipboard_button opsd_generate_button js-copy-email-btn" style="margin: 0;"
|
||||
href="javascript:void(0)" title="<?php _e('Copy to clipboard' , 'secure-downloads') ?>"
|
||||
><span class="opsd_text_hide_mobile0 btn_text_inside"><?php _e('Copy to clipboard' , 'secure-downloads') ?> </span><span class="glyphicon glyphicon-copy" aria-hidden="true"></span></a>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
copyEmailBtn = document.querySelector('.js-copy-email-btn');
|
||||
|
||||
copyEmailBtn.addEventListener('click', function(event) {
|
||||
|
||||
var inputid = 'show_email_content';
|
||||
var content;
|
||||
var editor = tinyMCE.get(inputid);
|
||||
if (editor) {
|
||||
// Ok, the active tab is Visual
|
||||
content = editor.getContent();
|
||||
} else {
|
||||
// The active tab is HTML, so just query the textarea
|
||||
content = $('#'+inputid).val();
|
||||
}
|
||||
console.log( content );
|
||||
|
||||
// Now get it as HTML (original here https://stackoverflow.com/questions/34191780/javascript-copy-string-to-clipboard-as-text-html )
|
||||
|
||||
// Create container for the HTML
|
||||
// [1]
|
||||
var container = document.createElement('div')
|
||||
container.innerHTML = content
|
||||
|
||||
// Hide element
|
||||
// [2]
|
||||
container.style.position = 'fixed'
|
||||
container.style.pointerEvents = 'none'
|
||||
container.style.opacity = 0
|
||||
|
||||
// Detect all style sheets of the page
|
||||
var activeSheets = Array.prototype.slice.call(document.styleSheets)
|
||||
.filter(function (sheet) {
|
||||
return !sheet.disabled
|
||||
})
|
||||
|
||||
// Mount the container to the DOM to make `contentWindow` available
|
||||
// [3]
|
||||
document.body.appendChild(container)
|
||||
|
||||
// Copy to clipboard
|
||||
// [4]
|
||||
window.getSelection().removeAllRanges()
|
||||
|
||||
var range = document.createRange()
|
||||
range.selectNode(container)
|
||||
window.getSelection().addRange(range)
|
||||
|
||||
// [5.1]
|
||||
document.execCommand('copy')
|
||||
|
||||
// [5.2]
|
||||
for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true
|
||||
|
||||
// [5.3]
|
||||
|
||||
//if ( ! navigator.clipboard ){
|
||||
|
||||
try{
|
||||
var successful = document.execCommand( 'copy' );
|
||||
var msg = successful ? 'successful' : 'unsuccessful';
|
||||
//console.log( 'Fallback: Copying text command was ' + msg );
|
||||
|
||||
var btn_today = new Date();
|
||||
var btn_date = btn_today.getFullYear()+'-'+(btn_today.getMonth()+1)+'-'+btn_today.getDate();
|
||||
var btn_time = btn_today.getHours() + ":" + btn_today.getMinutes() + ":" + btn_today.getSeconds();
|
||||
var btn_dateTime = ' '+btn_time;
|
||||
jQuery( '.js-copy-email-btn .btn_text_inside').html( 'Copied' + btn_dateTime + ' ' );
|
||||
|
||||
opsd_scroll_to( jQuery( '#opsd_sent_summary_subject' ) );
|
||||
|
||||
} catch ( err ){
|
||||
//console.error( 'Fallback: Oops, unable to copy', err );
|
||||
}
|
||||
// } else {
|
||||
// var type = "text/html";
|
||||
// var blob = new Blob([content], { type });
|
||||
// var data = [new ClipboardItem({ [type]: blob })];
|
||||
//
|
||||
// navigator.clipboard.write(data).then(
|
||||
// function () {
|
||||
// /* success */
|
||||
// console.log( 'Async: Copying to clipboard was successful!' );
|
||||
// },
|
||||
// function (err) {
|
||||
// /* failure */
|
||||
// console.error( 'Async: Could not copy text: ', err );
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
// [5.4]
|
||||
for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = false
|
||||
|
||||
// Remove the container
|
||||
// [6]
|
||||
document.body.removeChild(container)
|
||||
|
||||
// opsd_copy_text_to_clipboard( content );
|
||||
});
|
||||
|
||||
|
||||
|
||||
function opsd_fallback_copy_text_to_clipboard( text ){
|
||||
var textArea = document.createElement( "textarea" );
|
||||
textArea.value = text;
|
||||
|
||||
// Avoid scrolling to bottom
|
||||
textArea.style.top = "0";
|
||||
textArea.style.left = "0";
|
||||
textArea.style.position = "fixed";
|
||||
|
||||
document.body.appendChild( textArea );
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
try{
|
||||
var successful = document.execCommand( 'copy' );
|
||||
var msg = successful ? 'successful' : 'unsuccessful';
|
||||
console.log( 'Fallback: Copying text command was ' + msg );
|
||||
} catch ( err ){
|
||||
console.error( 'Fallback: Oops, unable to copy', err );
|
||||
}
|
||||
|
||||
document.body.removeChild( textArea );
|
||||
}
|
||||
|
||||
|
||||
function opsd_copy_text_to_clipboard( text ){
|
||||
if ( !navigator.clipboard ){
|
||||
opsd_fallback_copy_text_to_clipboard( text );
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText( text ).then( function (){
|
||||
console.log( 'Async: Copying to clipboard was successful!' );
|
||||
}, function ( err ){
|
||||
console.error( 'Async: Could not copy text: ', err );
|
||||
} );
|
||||
}
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
297
wp-content/plugins/secure-downloads/core/admin/page-settings.php
Normal file
297
wp-content/plugins/secure-downloads/core/admin/page-settings.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?php /**
|
||||
* @version 1.0
|
||||
* @package Secure Downloads
|
||||
* @category Content of Settings page
|
||||
* @author wpdevelop
|
||||
*
|
||||
* @web-site https://oplugins.com/
|
||||
* @email info@oplugins.com
|
||||
*
|
||||
* @modified 2015-11-02
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
|
||||
/** Show Content
|
||||
* Update Content
|
||||
* Define Slug
|
||||
* Define where to show
|
||||
*/
|
||||
class OPSD_Page_SettingsGeneral extends OPSD_Page_Structure {
|
||||
|
||||
private $settings_api = false;
|
||||
|
||||
public function in_page() {
|
||||
|
||||
return 'opsd-settings';
|
||||
}
|
||||
|
||||
/** Get Settings API class - define, show, update "Fields".
|
||||
*
|
||||
* @return object Settings API
|
||||
*/
|
||||
public function settings_api(){
|
||||
|
||||
if ( $this->settings_api === false )
|
||||
$this->settings_api = new OPSD_Settings_API_General();
|
||||
|
||||
return $this->settings_api;
|
||||
}
|
||||
|
||||
public function tabs() {
|
||||
|
||||
$tabs = array();
|
||||
|
||||
$tabs[ 'general' ] = array(
|
||||
'title' => __( 'General', 'secure-downloads' ) // Title of TAB
|
||||
, 'page_title' => __( 'General Settings', 'secure-downloads' ) // Title of Page
|
||||
, 'hint' => __( 'General Settings', 'secure-downloads' ) // Hint
|
||||
, '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-cog' // CSS definition of forn Icon
|
||||
, 'default' => true // Is this tab activated by default or not: true || false.
|
||||
);
|
||||
|
||||
$subtabs = array();
|
||||
|
||||
$subtabs['opsd-settings-url'] = array( 'type' => 'goto-link'
|
||||
, 'title' => __('URLs', 'secure-downloads')
|
||||
, 'show_section' => 'opsd_warning_url_settings_calendar_metabox'
|
||||
);
|
||||
|
||||
|
||||
$subtabs['opsd-settings-listing'] = array( 'type' => 'goto-link'
|
||||
, 'title' => __('Misc', 'secure-downloads')
|
||||
, 'show_section' => 'opsd_general_settings_opsd_misc_metabox'
|
||||
);
|
||||
|
||||
$subtabs['opsd-settings-menu-access'] = array( 'type' => 'goto-link'
|
||||
, 'title' => __('Plugin Menu', 'secure-downloads')
|
||||
, 'show_section' => 'opsd_general_settings_permissions_metabox'
|
||||
);
|
||||
|
||||
$subtabs['opsd-settings-uninstall'] = array( 'type' => 'goto-link'
|
||||
, 'title' => __('Uninstall', 'secure-downloads')
|
||||
, 'show_section' => 'opsd_general_settings_uninstall_metabox'
|
||||
);
|
||||
|
||||
$subtabs['opsd-settings-advanced'] = array( 'type' => 'goto-link'
|
||||
, 'title' => __('Advanced', 'secure-downloads')
|
||||
, 'show_section' => 'opsd_general_settings_advanced_metabox'
|
||||
);
|
||||
|
||||
|
||||
|
||||
$subtabs['form-save'] = array(
|
||||
'type' => 'button'
|
||||
, 'title' => __('Save Changes', 'secure-downloads')
|
||||
, 'form' => 'opsd_general_settings_form'
|
||||
);
|
||||
|
||||
|
||||
$tabs[ 'general' ][ 'subtabs' ] = $subtabs;
|
||||
|
||||
$tabs[ 'upgrade' ] = array(
|
||||
'title' => __( 'Addons', 'secure-downloads' ) // Title of TAB
|
||||
, 'page_title' => __( 'Extend functionaity', 'secure-downloads' ) // Title of Page
|
||||
, 'hint' => __( 'Extend functionaity with premium addons', 'secure-downloads' ) // Hint
|
||||
, 'link' => 'https://oplugins.com/plugins/secure-downloads/#premium' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
|
||||
, 'position' => 'right' // 'left' || 'right' || ''
|
||||
, 'css_classes' => '' // CSS class(es)
|
||||
, 'icon' => '' // Icon - link to the real PNG img
|
||||
, 'font_icon' => 'glyphicon glyphicon-shopping-cart' // CSS definition of forn Icon
|
||||
, 'default' => false // Is this tab activated by default or not: true || false.
|
||||
);
|
||||
|
||||
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.
|
||||
|
||||
$is_can = apply_opsd_filter('recheck_version', true); if ( ! $is_can ) { ?><script type="text/javascript"> jQuery(document).ready(function(){ jQuery( '.wpdvlp-sub-tabs').remove(); }); </script><?php return; }
|
||||
|
||||
|
||||
// Init Settings API & Get Data from DB ////////////////////////////////
|
||||
$this->settings_api(); // Define all fields and get values from DB
|
||||
|
||||
// Submit /////////////////////////////////////////////////////////////
|
||||
|
||||
$submit_form_name = 'opsd_general_settings_form'; // Define form name
|
||||
|
||||
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
|
||||
$this->update();
|
||||
}
|
||||
//$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 '<span class="wpdevelop">';
|
||||
opsd_js_for_items_page();
|
||||
echo '</span>';
|
||||
|
||||
|
||||
|
||||
// Content ////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<div class="clear" style="margin-bottom:10px;"></div>
|
||||
<span class="metabox-holder">
|
||||
<form name="<?php echo $submit_form_name; ?>" id="<?php echo $submit_form_name; ?>" action="" method="post">
|
||||
<?php
|
||||
// N o n c e field, and key for checking S u b m i t
|
||||
wp_nonce_field( 'opsd_settings_page_' . $submit_form_name );
|
||||
?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form_name; ?>" id="is_form_sbmitted_<?php echo $submit_form_name; ?>" value="1" />
|
||||
|
||||
<div class="opsd_settings_row opsd_settings_row_left" >
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_calendar', __('General', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'general' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_warning_url_settings_calendar', __('URL to pages after some errors', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'warning_url' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php /* ?>
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_calendar', __('Calendar', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'calendar' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_availability', __('Availability', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'availability' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_form', __('Form', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'form' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<?php */ ?>
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_opsd_misc', __('Miscellaneous', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'opsd_listing' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="opsd_settings_row opsd_settings_row_right">
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_information', __('Information', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'information' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_permissions', __('Plugin Menu', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'permissions' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_uninstall', __('Uninstall / deactivation', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'uninstall' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_advanced', __('Advanced', 'secure-downloads') ); ?>
|
||||
|
||||
<?php $this->settings_api()->show( 'advanced' ); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<input type="submit" value="<?php _e('Save Changes', 'secure-downloads'); ?>" class="button button-primary opsd_submit_button" />
|
||||
</form>
|
||||
<?php if ( ( isset( $_GET['system_info'] ) ) && ( $_GET['system_info'] == 'show' ) ) { ?>
|
||||
|
||||
<div class="clear" style="height:30px;"></div>
|
||||
|
||||
<?php opsd_open_meta_box_section( 'opsd_general_settings_system_info', 'System Info' ); ?>
|
||||
|
||||
<?php opsd_system_info(); ?>
|
||||
|
||||
<?php opsd_close_meta_box_section(); ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</span>
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
do_action( 'opsd_hook_settings_page_footer', 'general_settings' );
|
||||
|
||||
//debuge( 'Content <strong>' . basename(__FILE__ ) . '</strong> <span style="font-size:9px;">' . __FILE__ . '</span>');
|
||||
}
|
||||
|
||||
|
||||
public function update() {
|
||||
//debuge($_POST);
|
||||
$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.
|
||||
//debuge($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();
|
||||
|
||||
//debuge( basename(__FILE__), 'UPDATE', $_POST, $validated_fields);
|
||||
|
||||
// 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') );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//if ( $is_other_tab ) {
|
||||
//
|
||||
// if ( ( ! isset( $_GET['tab'] ) ) || ( $_GET['tab'] == 'general' ) ) { // If tab was not selected or selected default, then redirect it to the "form" tab.
|
||||
// $_GET['tab'] = 'form';
|
||||
// }
|
||||
//} else {
|
||||
// add_action('opsd_menu_created', array( new OPSD_Page_SettingsGeneral() , '__construct') ); // Executed after creation of Menu
|
||||
//}
|
||||
|
||||
add_action('opsd_menu_created', array( new OPSD_Page_SettingsGeneral() , '__construct') ); // Executed after creation of Menu
|
||||
|
||||
Reference in New Issue
Block a user