This commit is contained in:
2026-04-26 23:47:49 +02:00
parent 1b95f03d1e
commit b073e009d8
5288 changed files with 1112699 additions and 55536 deletions

View 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.

View File

@@ -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">
&nbsp;<?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'); ?>&nbsp;&nbsp;&nbsp;
<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>&nbsp;&nbsp;
<strong>Last Name</strong>:<span class="fieldvalue">Wilyson</span>&nbsp;&nbsp;
<strong>Email</strong>:<span class="fieldvalue">Wilyson.example@test.com</span>&nbsp;&nbsp;
<strong>Phone</strong>:<span class="fieldvalue">927-80-51</span>&nbsp;&nbsp;
<strong>Adults</strong>:<span class="fieldvalue"> 1</span>&nbsp;&nbsp;
<strong>Children</strong>:<span class="fieldvalue"></span>&nbsp;&nbsp;
<strong>Details</strong>:&nbsp;&nbsp;<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
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -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
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 &gt;
// $this->fields['content'] = html_entity_decode( $this->fields['content'] );// Convert &gt; 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]&lt;br/&gt;&lt;br/&gt;','&lt;br/&gt; [content]&lt;br/&gt;&lt;br/&gt;', htmlentities( ' <a href="[moderatelink]">'.__('here' , 'secure-downloads').'</a> ') . '&lt;br/&gt;&lt;br/&gt; ');
$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> &nbsp; ';
else
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-unchecked"></i> &nbsp; ';
$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>

View File

@@ -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 &gt;
// $this->fields['content'] = html_entity_decode( $this->fields['content'] );// Convert &gt; 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]&lt;br/&gt;&lt;br/&gt;','&lt;br/&gt; [content]&lt;br/&gt;&lt;br/&gt;', htmlentities( ' <a href="[moderatelink]">'.__('here' , 'secure-downloads').'</a> ') . '&lt;br/&gt;&lt;br/&gt; ');
$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> &nbsp; ';
else
$icon = '<i class="menu_icon icon-1x glyphicon glyphicon-unchecked"></i> &nbsp; ';
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>

View File

@@ -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' ); ?>&nbsp;&nbsp;</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

View File

@@ -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">&nbsp;</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

View 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') ?>&nbsp;&nbsp;</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' ) ); ?>&nbsp;&nbsp;');
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' ) ); ?>&nbsp;&nbsp;');
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') ?>&nbsp;&nbsp;</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
}

View 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

View File

@@ -0,0 +1,274 @@
<?php
/**
* @version 1.0
* @package oPlugins
* @category Installation
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-04-09, 2016-03-17
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Activation | Deactivation Class
*/
abstract class OPSD_Install {
private $init_option;
function __construct() {
$default_init_option_names = array(
'option-version_num' => 'securedownloads_version_num'
, 'option-is_delete_if_deactive' => 'securedownloads_is_delete_if_deactive'
, 'option-activation_process' => 'securedownloads_activation_process'
, 'transient-opsd_activation_redirect' => '_securedownloads_activation_redirect'
, 'message-delete_data' => '<strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . '<br />'
. sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>')
, 'link_settings' => '<a href="">Settings</a>'
, 'link_whats_new' => '<a href="">Whats New</a>'
);
$init_option = $this->get_init_option_names();
$this->init_option = wp_parse_args( $init_option, $default_init_option_names );
register_activation_hook( OPSD_FILE, array( $this, 'opsd_activate_initial' ) ); // WordPress > Plugins > "Activate" link.
register_deactivation_hook( OPSD_FILE, array( $this, 'opsd_deactivate' ) ); // WordPress > Plugins > "Deactivate" link.
add_filter('upgrader_post_install', array( $this, 'opsd_install_in_bulk_upgrade' ), 10, 2 ); // Upgrade during bulk upgrade of plugins
// Settings link at the plugin page
add_filter('plugin_action_links', array( $this, 'plugin_links'), 10, 2 );
// Warning message in plugin info
add_filter('plugin_row_meta', array( $this, 'plugin_row_meta'), 10, 4 );
$this->check_if_need_to_update(); // Check upgrade, if was no activation process
}
/** Must be overloaded in child CLASS
* Exmaple:
* return array(
'option-version_num' => 'securedownloads_version_num'
, 'option-is_delete_if_deactive' => 'securedownloads_is_delete_if_deactive'
, 'option-activation_process' => 'securedownloads_activation_process'
, 'transient-opsd_activation_redirect' => '_securedownloads_activation_redirect'
, 'message-delete_data' => '<strong>Warning !!!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . '<br />'
. sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the settings page.', '<strong>', '</strong>')
, 'link_settings' => '<a href="">Settings</a>'
, 'link_whats_new' => '<a href="">Whats New</a>'
);
*/
abstract function get_init_option_names();
/** Must be overloaded in child CLASS
* Exmaple:
*
return false
*/
abstract function is_update_from_lower_to_high_version();
////////////////////////////////////////////////////////////////////////////
// <editor-fold defaultstate="collapsed" desc=" Update info of plugin at the plugins section ">
/** Update info of plugin at the plugins section */
function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $context ) {
$this_plugin = plugin_basename( OPSD_FILE );
if ($plugin_file == $this_plugin ) {
$is_delete_if_deactive = get_opsd_option( $this->init_option['option-is_delete_if_deactive'] ); // check
if ($is_delete_if_deactive == 'On') { ?>
<div class="plugin-update-tr">
<div class="update-message notice inline notice-warning notice-altNO" style="font-size: 1em;line-height: 2em;margin:0 5px 10px;"><?php echo $this->init_option['message-delete_data']; ?></div>
</div>
<?php
}
/*
[$plugin_meta] => Array
(
[0] => Version 2.8.35
[1] => By wpdevelop
[2] => Visit plugin site
)
[$plugin_file] => securedownloads/OPSD.php
[$plugin_data] => Array
(
[Name] => pluginname
[PluginURI] => https://oplugins.com/plugins/secure-downloads/#demo
[Version] => 2.8.35
[Description] => Some description...
[Author] => wpdevelop
[AuthorURI] => https://oplugins.com/
[TextDomain] =>
[DomainPath] =>
[Network] =>
[Title] => Title
[AuthorName] => wpdevelop
)
[$context] => all
/**/
// Echo plugin description here
return $plugin_meta;
} else
return $plugin_meta;
}
// Adds Settings link to plugins settings
function plugin_links($links, $file) {
$this_plugin = plugin_basename( OPSD_FILE );
if ( $file == $this_plugin ) {
if ( ! empty( $this->init_option[ 'link_settings' ] ) )
array_unshift( $links, $this->init_option[ 'link_settings' ] );
if ( ! empty( $this->init_option[ 'link_whats_new' ] ) )
array_unshift( $links, $this->init_option[ 'link_whats_new' ] );
}
return $links;
}
// </editor-fold>
////////////////////////////////////////////////////////////////////////////
// Check about ability to upgrade, if was no activation process
private function check_if_need_to_update() {
if( is_admin() ) {
$opsd_version_num = get_option( $this->init_option['option-version_num'] );
if ($opsd_version_num === false )
$opsd_version_num = '0';
$is_make_activation = false;
if ( version_compare( OPSD_VERSION_NUM, $opsd_version_num) > 0 ) {
$is_make_activation = true;
} else {
// Check if we was update from free to paid or from lower to higher versions,
// and do not make normal activation. In this case we need to make update.
$is_make_activation = $this->is_update_from_lower_to_high_version();
}
// Add hook for initial activation.
if ( $is_make_activation ) {
add_action( 'plugins_loaded', array( $this, 'opsd_activate_initial' ) );
}
}
}
/** Upgrade during bulk upgrade of plugins
*
* @param type $return
* @param type $hook_extra
* @return type
*/
public function opsd_install_in_bulk_upgrade( $return, $hook_extra ){
if ( is_wp_error( $return ) )
return $return;
if ( isset( $hook_extra ) )
if ( isset( $hook_extra['plugin'] ) ) {
$file_name = basename( OPSD_FILE );
$pos = strpos( $hook_extra['plugin'], trim( $file_name ) );
if ( $pos !== false ) {
$this->opsd_activate();
}
}
return $return;
}
/** User clicked on "Activate" link at Plugins Menu.
*
* @return type
*/
public function opsd_activate_initial(){
// Activate the plugin
$this->opsd_activate();
// Bail if this demo or activating from network, or bulk
if ( is_network_admin() || isset( $_GET['activate-multi'] ) || opsd_is_this_demo() )
return;
// Add the transient to redirect - Showing Welcome screen
set_transient( $this->init_option['transient-opsd_activation_redirect'], true, 30 );
}
////////////////////////////////////////////////////////////////////////////
/** Run Activate */
public function opsd_activate() {
if ( ( function_exists( 'set_time_limit' ) ) && // Try to extend script running to 15 minutes
( ! in_array( ini_get( 'safe_mode' ), array( '1', 'On' ) ) ) // It's doesn't work, if PHP have SAFE MODE ON
) set_time_limit( 900 );
ini_set('memory_limit','256M'); //FixIn:6.1.1.15
update_opsd_option( $this->init_option['option-activation_process'], 'On' );
make_opsd_action( 'opsd_activation' ); // S T A R T
update_opsd_option( $this->init_option['option-version_num'], OPSD_VERSION_NUM );
update_opsd_option( $this->init_option['option-activation_process'], 'Off');
}
/** Run Deactivate */
public function opsd_deactivate() {
if ( ( function_exists( 'set_time_limit' ) ) && // Try to extend script running to 15 minutes
( ! in_array( ini_get( 'safe_mode' ), array( '1', 'On' ) ) ) // It's doesn't work, if PHP have SAFE MODE ON
) set_time_limit( 900 );
$is_delete_if_deactive = get_opsd_option( $this->init_option['option-is_delete_if_deactive'] ); // check
if ( $is_delete_if_deactive == 'On' ) {
make_opsd_action( 'opsd_deactivation' ); // F I N I S H
delete_opsd_option( $this->init_option['option-version_num'] );
delete_opsd_option( $this->init_option['option-activation_process'] );
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,534 @@
<?php
/**
* @version 1.1
* @package General Emails API
* @category General Emails API Fields for Settings page and Functions for Sending emails.
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
* @modified 2016-05-12, 2015-10-06
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Email Settings API - Saving different options
abstract class OPSD_Emails_API extends OPSD_Settings_API {
public $sending;
public $replace = array();
/** Email Settings API Constructor
* During creation, system try to load values from DB, if exist.
*
* @param type $id - "Pure Email Template name
*/
public function __construct( $id, $init_fields_values = array()) {
$options = array(
'db_prefix_option' => 'opsd_email_'
, 'db_saving_type' => 'togather' // { 'togather' (Default), 'separate', 'separate_prefix' }
);
// Email template saved as:
// ( "prefix_email_" . $id ) >>> "prefix_email_new_admin"
parent::__construct( $id, $options, $init_fields_values ); // Define ID of Setting page and options
add_filter( 'phpmailer_init', array( $this, 'process_multipart' ) ); // For multipart messages
add_action( 'wp_mail_failed', array($this, 'email_error_parse') ); // Parse any errors during sending emails.
}
/** This function must be overriden - Initialise Settings Form Fields
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'
);
// ...
}
/**/
// <editor-fold defaultstate="collapsed" desc=" Suport functions " >
/** List of preg* regular expression patterns to search for replace in plain emails.
* More: https://raw.github.com/ushahidi/wp-silcc/master/class.html2text.inc
*/
private function get_plain_search_array() {
return array(
"/\r/", // Non-legal carriage return
'/&(nbsp|#160);/i', // Non-breaking space
'/&(quot|rdquo|ldquo|#8220|#8221|#147|#148);/i', // Double quotes
'/&(apos|rsquo|lsquo|#8216|#8217);/i', // Single quotes
'/&gt;/i', // Greater-than
'/&lt;/i', // Less-than
'/&#38;/i', // Ampersand
'/&#038;/i', // Ampersand
'/&amp;/i', // Ampersand
'/&(copy|#169);/i', // Copyright
'/&(trade|#8482|#153);/i', // Trademark
'/&(reg|#174);/i', // Registered
'/&(mdash|#151|#8212);/i', // mdash
'/&(ndash|minus|#8211|#8722);/i', // ndash
'/&(bull|#149|#8226);/i', // Bullet
'/&(pound|#163);/i', // Pound sign
'/&(euro|#8364);/i', // Euro sign
'/&#36;/', // Dollar sign
'/&[^&;]+;/i', // Unknown/unhandled entities
'/[ ]{2,}/' // Runs of spaces, post-handling
);
}
/** List of symbols "for Replace To" */
private function get_plain_replace_array() {
return array(
'', // Non-legal carriage return
' ', // Non-breaking space
'"', // Double quotes
"'", // Single quotes
'>', // Greater-than
'<', // Less-than
'&', // Ampersand
'&', // Ampersand
'&', // Ampersand
'(c)', // Copyright
'(tm)', // Trademark
'(R)', // Registered
'--', // mdash
'-', // ndash
'*', // Bullet
'£', // Pound sign
'EUR', // Euro sign. € ?
'$', // Dollar sign
'', // Unknown/unhandled entities
' ' // Runs of spaces, post-handling
);
}
/** Esacpe and replace any HTML entities
*
* @param type $string
* @return string
*/
public function esc_to_plain_text( $string ) {
// //Replace <a href="http://server.com">Link</a> to Link( http://server.com )
// $pattern = "/<a(.*)+href=[\"|']+([^\"']+)(?=(\"|'))[^>]*>(.*)<\/a>/" ; //"/(?<=href=(\"|'))[^\"']+(?=(\"|'))/i";
// $newurl = "$4 ($2)";
// $string = preg_replace($pattern,$newurl,$string);
$newstring = preg_replace( $this->get_plain_search_array(), $this->get_plain_replace_array(), strip_tags( $string ) );
return $newstring;
}
/** Set array for replacing shortcodes in Email Content and Subject
*
* @param array $replace - if this parameter skipped, then array reseted to empty array
*/
function set_replace( $replace = array() ) {
$this->replace = $replace;
}
/** Replace shortcodes in givven string. Usually its Email Content and Subject
*
* @param string $subject
*/
public function replace_shortcodes( $subject ) {
$defaults = array(
'ip' => apply_opsd_filter( 'opsd_get_user_ip' )
, 'blogname' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
, 'siteurl' => get_site_url()
);
$replace = wp_parse_args( $this->replace, $defaults );
foreach ( $replace as $replace_shortcode => $replace_value ) {
if ( is_string( $replace_value ) ) { //FixIn: 1.1.3.1
$replace_shortcode = (string) $replace_shortcode;
$replace_value = (string) $replace_value;
$subject = str_replace( array( '[' . $replace_shortcode . ']'
, '{' . $replace_shortcode . '}' )
, $replace_value
, $subject );
}
}
return $subject;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc=" Pure Email functions " >
/** For MultiPart email define plain text - AltBody
*
* Also additionaly fix Sender - its have to be same as From
*
* @param PHPMailer $mailer
* @return PHPMailer
*/
public function process_multipart( $mailer ) {
//if ( $this->sending && $this->get_email_content_type() == 'multipart' ) {
if ( $this->sending ) {
if ( $this->get_email_content_type() == 'multipart' )
$mailer->AltBody = wordwrap( $this->esc_to_plain_text( $this->replace_shortcodes( $this->get_content_plain() ) ) );
$mailer->Sender = $mailer->From;
//$this->sending = false; // If we set it to false, then we can not trigger for any Mail errors in this CLASS
}
return $mailer;
}
/** Get type of Email: 'plain' | 'html' | 'multipart'
*
* @return string
*/
public function get_email_content_type() {
return $this->fields_values['email_content_type'] && class_exists( 'DOMDocument' ) ? $this->fields_values['email_content_type'] : 'plain';
}
/** Get Email Content Type: 'text/plain' | 'text/html' | 'multipart/alternative'
*
* @return string
*/
public function get_content_type() {
switch ( $this->get_email_content_type() ) {
case 'html' :
return 'text/html';
case 'multipart' :
return 'multipart/alternative';
default :
return 'text/plain';
}
}
/** Define Email Headers. For exmaple: "Conte type:" 'text/plain' | 'text/html' | 'multipart/alternative' or "From": Name <email@server.com>
*
* @return string
*/
public function get_headers( $additional_params = array() ) {
$mail_headers = '';
$from_address = $this->get_from__email_address();
if ( ! empty( $from_address ) ) {
$mail_headers .= 'From: ' . $this->get_from__name() . ' <' . $from_address . '> ' . "\r\n" ;
} else {
/* If we don't have an email from the input headers default to wordpress@$sitename
* Some hosts will block outgoing mail from this address if it doesn't exist but
* there's no easy alternative. Defaulting to admin_email might appear to be another
* option but some hosts may refuse to relay mail from an unknown domain. See
* https://core.trac.wordpress.org/ticket/5007.
*/
}
$mail_headers .= 'Content-Type: ' . $this->get_content_type() . "\r\n" ;
$mail_headers = apply_filters( 'opsd_email_api_get_headers_after', $mail_headers, $this->id, $this->fields_values , $this->replace, $additional_params );
return $mail_headers;
}
/** Get Content of Email
*
* @return string
*/
public function get_content() {
if ( $this->get_email_content_type() == 'plain' ) {
$email_content = $this->esc_to_plain_text( $this->replace_shortcodes( $this->get_content_plain() ) );
} else {
$email_content = $this->replace_shortcodes( $this->get_content_html() );
}
$email_content = apply_filters( 'opsd_email_api_get_content_after' , $email_content, $this->id, $this->get_email_content_type() );
// Remove all shortcodes, which is not replaced early.
$email_content = preg_replace ('/[\[\{][a-zA-Z0-9.,_-]{0,}[\]\}]/', '', $email_content);
return wordwrap( $email_content, 100 );
}
/** Get Email Content as Text (from Plain Text template)
*
* @return string
*/
function get_content_plain() {
//require_once( dirname(__FILE__) . '/emails_tpl/standard-text-tpl.php' );
//require_once( dirname(__FILE__) . '/emails_tpl/plain-text-tpl.php' );
if ( isset( $this->fields_values['template_file'] ) ) {
$email_tpl_name = $this->fields_values['template_file'];
} else {
$email_tpl_name = 'plain';
}
if ( file_exists( dirname(__FILE__) . '/emails_tpl/'. $email_tpl_name .'-text-tpl.php' ) )
require_once( dirname(__FILE__) . '/emails_tpl/'. $email_tpl_name .'-text-tpl.php' );
else
require_once( dirname(__FILE__) . '/emails_tpl/plain-text-tpl.php' );
$fields_values = $this->fields_values;
$fields_values = apply_filters( 'opsd_email_api_get_content_before' , $fields_values, $this->id , 'plain' ); //Ability to parse 'content', 'header_content', 'footer_content' for different languges, etc ....
if ( function_exists( 'opsd_email_template_' . $email_tpl_name . '_text' ) )
$plain_email = call_user_func_array( 'opsd_email_template_' . $email_tpl_name . '_text' , array( $fields_values ) );
else
$plain_email = opsd_email_template_text( $fields_values );
// Replace <p> | <br> to \n
$plain_email = preg_replace( '/<(br|p)[\t\s]*[\/]?>/i', "\n", $plain_email );
// $plain_email = str_replace( array('<br/>', '<br>'), "\n", $plain_email );
return $plain_email;
}
/** Get Email Content as HTML (from HTML template)
*
* @return type
*/
function get_content_html() {
// Load specific Email Template: ///////////////////////////////////
if ( isset( $this->fields_values['template_file'] ) ) {
$email_tpl_name = $this->fields_values['template_file'];
} else {
$email_tpl_name = 'plain';
}
//require_once( dirname(__FILE__) . '/emails_tpl/standard-html-tpl.php' );
//require_once( dirname(__FILE__) . '/emails_tpl/plain-html-tpl.php' );
if ( file_exists( dirname(__FILE__) . '/emails_tpl/'. $email_tpl_name .'-html-tpl.php' ) )
require_once( dirname(__FILE__) . '/emails_tpl/'. $email_tpl_name .'-html-tpl.php' );
else
require_once( dirname(__FILE__) . '/emails_tpl/plain-html-tpl.php' );
////////////////////////////////////////////////////////////////////
$fields_values = $this->fields_values;
$fields_values = apply_filters( 'opsd_email_api_get_content_before' , $fields_values, $this->id , 'html' ); //Ability to parse 'content', 'header_content', 'footer_content' for different languges, etc ....
if ( function_exists( 'opsd_email_template_' . $email_tpl_name . '_html' ) )
$html_email = call_user_func_array( 'opsd_email_template_' . $email_tpl_name . '_html' , array( $fields_values ) );
else
$html_email = opsd_email_template_html( $fields_values );
return $html_email;
}
/** Get escaped Email Subject
*
* @return string
*/
public function get_subject() {
$subject = $this->fields_values['subject'];
$subject = apply_filters( 'opsd_email_api_get_subject_before' , $subject, $this->id );
$subject = $this->esc_to_plain_text( $this->replace_shortcodes( $subject ) );
$subject = apply_filters( 'opsd_email_api_get_subject_after' , $subject, $this->id );
return $subject;
}
/** Get escapeed Name from any not supporting characters
*
* @return string
*/
public function get_from__name() {
return wp_specialchars_decode( esc_html( stripslashes( $this->fields_values['from_name'] ) ), ENT_QUOTES );
}
/** Get sanitized Email address
*
* @return type
*/
public function get_from__email_address() {
return sanitize_email( $this->fields_values['from'] );
}
/** For future support, right now does not support
*
* @return empty string
*/
public function get_attachments() {
return '';
}
/** Check email and format it
*
* @param string $emails
* @return string
*/
public function validate_emails( $emails ) {
$emails = str_replace(';', ',', $emails);
if ( !is_array( $emails ) )
$emails = explode( ',', $emails );
$emails_list = array();
foreach ( (array) $emails as $recipient ) {
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
$recipient_name = '';
if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
if ( count( $matches ) == 3 ) {
$recipient_name = $matches[1];
$recipient = $matches[2];
}
} else {
// Check about correct format of email
if( preg_match( '/([\w\.\-_]+)?\w+@[\w\-_]+(\.\w+){1,}/im', $recipient, $matches ) ) { //FixIn: 8.7.7.2
$recipient = $matches[0];
}
}
//$recipient_name = str_replace('"', '', $recipient_name);
$recipient_name = trim( wp_specialchars_decode( esc_html( stripslashes( $recipient_name ) ), ENT_QUOTES ) );
$emails_list[] = ( empty( $recipient_name ) ? '' : $recipient_name . ' ' )
. '<' . sanitize_email( $recipient ) . '>';
}
$emails_list = implode( ',', $emails_list );
return $emails_list;
}
/**
* Make Email Sending by using wp_mail standard function.
*
* @param string $to - Email
* @param array $replace - accociated array of values to replace in email Body and Subject. Exmaple: array( 'name' => 'Jo', 'secondname' => 'Smith' )
* @return boolean Sent or Failed to send.
*/
public function send( $to = '', $replace = array() ) {
$return = false;
// if ( empty( $to ) )
// return $return;
$this->sending = true;
$this->set_replace( $replace );
$to = $this->validate_emails( $to );
$subject = $this->get_subject();
$message = $this->get_content();
$headers = $this->get_headers();
$attachments = $this->get_attachments();
//debuge('In email', htmlentities($to), $subject, htmlentities($message), $headers, $attachments) ;
$is_send_email = true;
$is_send_email = apply_filters( 'opsd_email_api_is_allow_send', $is_send_email, $this->id, $this->fields_values );
if ( $is_send_email )
$return = wp_mail( $to, $subject, $message, $headers, $attachments );
$this->sending = false;
// Send Copy to admin email
if (
( isset( $this->fields_values['copy_to_admin'] ) )
&& ( $this->fields_values['copy_to_admin'] == 'On' )
){
$this->sending = true;
$subject = __('Email copy to', 'secure-downloads') . ' ' . str_replace( array( '<', '>' ), '', $to) . ' - ' . $subject;
$headers = $this->get_headers( array( 'reply' => $to ) );
$to = $this->validate_emails( $this->get_from__name() . ' <' . $this->get_from__email_address() . '> ' );
$is_send_email = apply_filters( 'opsd_email_api_is_allow_send_copy', $is_send_email, $this->id, $this->fields_values );
if ( $is_send_email )
$return_copy = wp_mail( $to, $subject, $message, $headers, $attachments );
$this->sending = false;
}
$this->set_replace(); // Reset replace parameter
return $return;
}
// </editor-fold>
/** Show possible erros during sending emails.
*
* @param type $wp_error_object - new WP_Error( $e->getCode(), $e->getMessage(), $mail_error_data )
*/
public function email_error_parse( $wp_error_object ) {
//debuge( $wp_error_object );
if ( $this->sending ) { // Check if this error generated for email relative to this class.
$error_description_array = array();
if ( isset( $wp_error_object->errors ) )
foreach ( $wp_error_object->errors as $key_error => $error_description ) {
$error_description_array[] = implode(' ', $error_description );
}
if ( ! empty( $error_description_array ) ) {
$error_description = implode(' ', $error_description_array ) ;
do_action('opsd_email_sending_error', $wp_error_object, $error_description );
} else {
do_action('opsd_email_sending_error', $wp_error_object, '' );
}
}
}
}

View File

@@ -0,0 +1,259 @@
<?php /**
* @version 1.1
* @package Any
* @category Menu in Admin Panel
* @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_Admin_Menus {
/* Static Variables */
static $capability = array( 'administrator' => 'activate_plugins',
'editor' => 'publish_pages',
'author' => 'publish_posts',
'contributor' => 'edit_posts',
'subscriber' => 'read'
);
protected $menu_tag;
protected $menu_title;
protected $menu_title_second; // For root menu chnage second title in submenu - little hack
protected $page_header; // Header - H2, in page content
protected $browser_header; // Browser Header Title
protected $in_menu;
protected $user_role; // Acceess Role for current menu item
protected $mune_icon_url; // Icon - if used 'none', then you can define it in the CSS backgound: .toplevel_page_opsd .wp-menu-image { background-image: url("../img/icon-16x16.png"); background-position: 7px 7px; } But its mean that you are need to load this CSS in every admin page.
public $root_position; /* Positions for Core Menu Items
2 Dashboard
4 Separator
5 Posts
10 Media
15 Links
20 Pages
25 Comments
59 Separator
60 Appearance
65 Plugins
70 Users
75 Tools
80 Settings
99 Separator
*/
function __construct( $slug, $param = array() ) {
$this->in_menu = false;
$this->menu_tag = $slug; // For exmaple: 'opsd-settings' - its 'page' parameter in URL
if ( isset( $param['menu_title'] ) ) $this->menu_title = $param['menu_title'];
if ( isset( $param['menu_title_second'] ) ) $this->menu_title_second = $param['menu_title_second'];
if ( isset( $param['page_header'] ) ) $this->page_header = $param['page_header'];
if ( isset( $param['browser_header'] ) ) $this->browser_header = $param['browser_header'];
if ( isset( $param['in_menu'] ) ) $this->in_menu = $param['in_menu'];
if ( isset( $param['position'] ) ) $this->root_position = $param['position'];
else $this->root_position = null;
if ( isset( $param['mune_icon_url'] ) ) $this->mune_icon_url = $param['mune_icon_url'];
else $this->mune_icon_url = 'none';
if ( isset( $param['user_role'] ) ) $this->user_role = $param['user_role'];
else $this->user_role = 'subscriber';
add_action( 'admin_menu', array($this, 'new_admin_page'), 10 );
add_action( 'admin_menu', array($this, 'change_second_root_menu_title'), 11 ); // Change Title of Submenu title for root menu item
}
public function load_js() {
do_action( 'opsd_load_js_on_admin_page' );
}
public function load_css() {
do_action( 'opsd_load_css_on_admin_page' );
}
/** Define Plugin Menu Page
*
*/
public function new_admin_page(){
if ( $this->in_menu == 'root' ) { // Main Menu
$page = $this->create_plugin_menu(
$this->browser_header // Browser Page Header Title
, $this->menu_title // Menu Title
, ( ( isset( self::$capability[ $this->user_role ] ) ) ? self::$capability[ $this->user_role ] : self::$capability[ 'subscriber' ] ) // Capabilities
, $this->menu_tag // Slug // I was used early -> plugin_basename(OPSD_FILE).'opsd'
, $this->mune_icon_url // Icon // - if used 'none', then you can define it in the CSS backgound: .toplevel_page_opsd .wp-menu-image { background-image: url("../img/icon-16x16.png"); background-position: 7px 7px; } But its mean that you are need to load this CSS in every admin page.
, array( $this, 'content' ) // Function for output content of page
);
} else { // Sub Menu
$page = $this->create_plugin_submenu(
$this->in_menu // The slug name for parent menu (or file name of standard WordPress admin page)
, $this->browser_header // Page Title
, $this->menu_title // Menu Title
, ( ( isset( self::$capability[ $this->user_role ] ) ) ? self::$capability[ $this->user_role ] : self::$capability[ 'subscriber' ] ) // Capabilities
, $this->menu_tag // Slug
, array( $this, 'content' ) // Function for output content of page
);
}
//do_action('opsd_define_settings_pages', $this->menu_tag ); // Define sub classes, like: page-settings-general.php $this->menu_tag - 'opsd-settings' - its 'page' parameter in URL
do_action('opsd_menu_created', $this->menu_tag ); // Define sub classes, like: page-settings-general.php $this->menu_tag - 'opsd-settings' - its 'page' parameter in URL
do_action('opsd_define_nav_tabs', $this->menu_tag ); // Define Nav tabs.
}
/** Content of the Menu Page
*
Define page S t r u c t u r e, nav T A B s , set N O N C E: opsd_ajax_admin_nonce field
in ..\any\class\class-admin-page-structure.php
then show page C O N T E N T in files, like page-structure.php
$this->menu_tag - 'opsd-settings' - its 'page' parameter in URL
*/
public function content() {
do_action('opsd_page_structure_show', $this->menu_tag );
}
/** Hack for changing Root 2nd Submenu Title
*
* @global type $submenu
*/
public function change_second_root_menu_title() {
// Change Title of the Main menu inside of submenu
global $submenu;
if ( ( $this->in_menu == 'root' )
&& ( isset( $submenu[ $this->menu_tag ] ) )
&& ( isset( $this->menu_title_second ) )
) {
$submenu[ $this->menu_tag ][0][0] = $this->menu_title_second;
}
}
/** Add Menu
*
* @param type $menu_page_title
* @param type $menu_title
* @param type $capability
* @param type $menu_slug
* @param type $mune_icon_url
* @param type $page_content
* @param type $page_css
* @param type $page_js
* @return type
*/
protected function create_plugin_menu($menu_page_title, $menu_title, $capability, $menu_slug, $mune_icon_url, $page_content ) {
/**
* add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );
* @return string The resulting page's hook_suffix
*/
//FixIn: 2.0.1.2
// The url to the icon to be used for this menu. Using 'none' would leave div.wp-menu-image empty so an icon can be added as background with CSS.
if ( '<svg' == substr( $mune_icon_url, 0, 4 ) ) {
/*
$mune_icon_url_svg = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="" viewBox="-2 -1 20 20">
<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM2 2a1 1 0 0 0-1 1v1h14V3a1 1 0 0 0-1-1H2zm13 3H1v9a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V5z"/>
<path d="M9 7.5a.5.5 0 0 1 .5-.5H15v2H9.5a.5.5 0 0 1-.5-.5v-1zm-2 3v1a.5.5 0 0 1-.5.5H1v-2h5.5a.5.5 0 0 1 .5.5z"/>
</svg>';
*/
$mune_icon_url = sprintf( 'data:image/svg+xml;base64,%s', base64_encode( $mune_icon_url ) );
} elseif ( $mune_icon_url == 'none' ) {
$mune_icon_url = 'none';
} elseif ( empty( $mune_icon_url ) ) {
$mune_icon_url = '';
} else {
$mune_icon_url = plugins_url( $mune_icon_url, OPSD_FILE );
}
$page = add_menu_page( $menu_page_title, // The text to be displayed in the title tags of the page when the menu is selected
$menu_title, // The text to be used for the menu
$capability, // The capability required for this menu to be displayed to the user.
$menu_slug, // The slug name to refer to this menu by (should be unique for this menu)
$page_content, // The function to be called to output the content for this page.
$mune_icon_url//(($mune_icon_url=='none')?'none':((empty($mune_icon_url))?'':plugins_url($mune_icon_url, OPSD_FILE)) ) // The url to the icon to be used for this menu. Using 'none' would leave div.wp-menu-image empty so an icon can be added as background with CSS.
, $this->root_position /* @param int $position The position in the menu order this one should appear
* Positions for Core Menu Items
2 Dashboard
4 Separator
5 Posts
10 Media
15 Links
20 Pages
25 Comments
59 Separator
60 Appearance
65 Plugins
70 Users
75 Tools
80 Settings
99 Separator
*/
);
add_action( 'admin_print_styles-' . $page, array( $this, 'load_css' ) );
add_action( 'admin_print_scripts-' . $page, array( $this, 'load_js' ) );
return $page;
}
/** Add Sub Menu
*
* @param type $parent_menu_slug - The slug name for the parent menu (or the file name of a standard WordPress admin page)
* @param type $menu_page_title
* @param type $menu_title
* @param type $capability
* @param type $menu_slug
* @param type $page_content
* @param type $page_css
* @param type $page_js
* @return type
*/
protected function create_plugin_submenu( $parent_menu_slug, $menu_page_title, $menu_title, $capability, $menu_slug, $page_content ) {
/**
* function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' );
* @return string|bool The resulting page's hook_suffix, or false if the user does not have the capability required.
*/
$page = add_submenu_page(
$parent_menu_slug, // The slug name for the parent menu (or the file name of a standard WordPress admin page)
$menu_page_title, // The text to be displayed in the title tags of the page when the menu is selected
$menu_title, // The text to be used for the menu
$capability, // The capability required for this menu to be displayed to the user.
$menu_slug, // The slug name to refer to this menu by (should be unique for this menu)
$page_content // The function to be called to output the content for this page.
);
add_action( 'admin_print_styles-' . $page, array( $this, 'load_css' ) );
add_action( 'admin_print_scripts-' . $page, array( $this, 'load_js' ) );
return $page;
}
}

View File

@@ -0,0 +1,665 @@
<?php /**
* @version 1.1
* @package Any
* @category Page Structure in Admin Panel
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-11-02
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit, if accessed directly
/** Define Settings Page Structure */
abstract class OPSD_Page_Structure {
protected static $nav_tabs; // Tabs array, same for all objects
private $current_page_params; // Parameters for current page, if this page selected, otherwise its = empty array()
private $is_only_icons = false;
protected $tags; // Defining Name of parameter in GET request for Navigation TOP and BOTTOM tabs
// - $_GET[ 'tab' ] == 'payment'
// - $_GET[ 'subtab' ] == 'paypal'
public function __construct() {
$this->tags = array();
$this->tags['tab'] = 'tab'; // Defining Name of parameter in GET request - $_GET[ 'tab' ] == 'payment'
$this->tags['subtab'] = 'subtab'; // Defining Name of parameter in GET request - $_GET[ 'subtab' ] == 'paypal'
$this->current_page_params = array();
self::$nav_tabs = array();
add_action('opsd_define_nav_tabs', array( $this, 'opsd_define_nav_tabs' ) ); // This Hook fire after creation menu in class OPSD_Admin_Menus
add_action('opsd_page_structure_show', array( $this, 'content_structure' ) ); // This Hook fire in the class OPSD_Admin_Menus for showing page content of specific menu
}
////////////////////////////////////////////////////////////////////////////
// Abstract Methods
////////////////////////////////////////////////////////////////////////////
/** Define slug in what menu to show this page. // Parameter relative: $_GET['page'].
*
* @return string
*
* Example:
return 'opsd-settings';
*/
abstract public function in_page();
/** Define Tabs and Subtabs of this Admin Page
*
* @return array();
* Example:
$tabs = array();
$tabs[ 'form' ] = array(
'title' => __('Form', 'secure-downloads') // Title of TAB
, 'hint' => __('Customizaton of Form Fields', 'secure-downloads') // Hint
, 'page_title' =>ucwords( __('Form fields', '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-edit' // 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()
);
$tabs[ 'upgrade' ] = array(
'title' => __('Upgrade', 'secure-downloads') // Title of TAB
, 'hint' => __('Upgrade to higher version', 'secure-downloads') // Hint
//, 'page_title' => __('Upgrade', 'secure-downloads') // 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['fields'] = array(
'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
, 'title' => __('Form', 'secure-downloads') // Title of TAB
, 'page_title' => __('Form Settings', 'secure-downloads') // Title of Page
, 'hint' => __('Customization of Form Settings', 'secure-downloads') // 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' | 'html'
);
$subtabs['form-goto'] = array(
'type' => 'goto-link' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
, 'title' =>ucwords( __('Form fields', 'secure-downloads') ) // Title of TAB
, 'hint' => '' // Hint
, 'show_section' => 'id_of_show_section' // ID of HTML element, for scroll to.
);
ob_start();
...
$html_element_data = ob_get_clean();
$subtabs['form-selection'] = array(
'type' => 'html' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
, 'html' => $html_element_data
);
$subtabs['form-save'] = array(
'type' => 'button' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
, 'title' => __('Save Changes', 'secure-downloads') // Title of TAB
, 'form' => 'opsd_form' // Required for 'button'! Name of Form to submit
);
$tabs[ 'form' ][ 'subtabs' ] = $subtabs;
return $tabs;
*/
abstract public function tabs();
/** Show Content of this page - Main function.
*
* In top of this function have to be checking ubout Update (saving POST request).
*
* Exmaple:
// S u b m i t ///////////////////////////////////////////////////////
$this_submit_form = 'opsd_emails_toolbar'; // Define form name
if ( isset( $_POST['is_form_sbmitted_'. $this_submit_form ] ) ) {
// Check N o n c e
check_admin_referer( 'opsd_settings_page_' . $this_submit_form ); // Its stop show anything on submiting, if its not refear to the original page
// Make Update of settings
$edit_field_data = $this->update_opsd_emails_toolbar( $menu_slug );
}
////////////////////////////////////////////////////////////////////////
*/
abstract public function content();
////////////////////////////////////////////////////////////////////////////
// C O N T E N T
////////////////////////////////////////////////////////////////////////////
/** General Page Structure
*
* @param string $page_tag - its the same that return $this->in_page()
*/
public function content_structure( $page_tag ) {
if ( ! $this->is_page_activated() )
return false;
$active_page_tab = $active_page_subtab = '';
if ( ( isset( $this->current_page_params['tab'] ) ) && ( ! empty( $this->current_page_params['tab']['tag'] ) ) )
$active_page_tab = $this->current_page_params['tab']['tag'];
if ( ( isset( $this->current_page_params['subtab'] ) ) && ( ! empty( $this->current_page_params['subtab']['tag'] ) ) )
$active_page_subtab = $this->current_page_params['subtab']['tag'];
$is_show_this_page = apply_filters( 'opsd_before_showing_settings_page_is_show_page', true, $page_tag, $active_page_tab, $active_page_subtab ); // Fires Before showing settings Content page
if ( $is_show_this_page === false ) return false;
do_action( 'opsd_before_settings_content', $page_tag, $active_page_tab, $active_page_subtab ); // Fires Before showing settings Content page
?><div id="<?php echo $page_tag; ?>-admin-page" class="wrap opsd_page"><?php
do_action( 'opsd_settings_before_header', $page_tag, $active_page_tab, $active_page_subtab ); // FixIn: N
?>
<h1 class="opsd_header"><div class="opsd_header_icon"></div><?php echo $this->get_page_header_h1(); ?></h1><?php
do_action( 'opsd_settings_after_header', $page_tag, $active_page_tab, $active_page_subtab ); // FixIn: N
?>
<div class="opsd_admin_message"></div>
<div class="opsd_admin_page">
<div id="ajax_working"></div>
<div class="clear opsd_header_margin"></div>
<div id="ajax_respond" class="ajax_respond" style="display:none;"></div>
<?php
// T A B S
$this->show_tabs_structure( $page_tag );
wp_nonce_field('opsd_ajax_admin_nonce', "opsd_admin_panel_nonce" , true , true );
// C o n t e n t
if ( ( isset( $this->current_page_params['subtab'] ) ) && ( isset( $this->current_page_params['subtab']['content'] ) ) ) {
call_user_func( array( $this, $this->current_page_params['subtab']['content'] ) );
} else if ( ( isset( $this->current_page_params['tab'] ) ) && ( isset( $this->current_page_params['tab']['content'] ) ) ) {
call_user_func( array( $this, $this->current_page_params['tab']['content'] ) );
} else
$this->content();
do_action('opsd_show_settings_content' , $page_tag, $active_page_tab, $active_page_subtab );
?></div>
</div><?php
do_action( 'opsd_after_settings_content', $page_tag, $active_page_tab, $active_page_subtab ); // Fires After showing settings Content page
}
////////////////////////////////////////////////////////////////////////////
// Active Page Parameters
////////////////////////////////////////////////////////////////////////////
/** Check if this page selected (active), depend from the GET parameter
* If selected, then define Current Page Parameters.
*
* @return boolean
*/
private function is_page_activated() {
$is_page_selected = false;
$this_page = $this->in_page();
foreach ( $this->tabs() as $this_tab_tag => $this_tab ) { // Get First Tab Element, which MUST be subtab element, all other tabs, can be links, not really showing content!!!
break;
}
if ( empty( $this_tab ) )
return $this_page; // this page empty - tabs is empty array, probabaly its was redefined in child CLASS to $tabs = array(); for not ability to open this page.
$this_subtab_tag = 0;
$this_subtab = array( 'default' => false );
if ( isset( $this_tab['subtabs'] ) )
foreach ( $this_tab['subtabs'] as $temp_this_subtab_tag => $temp_this_subtab ) {
if ( $temp_this_subtab['type'] == 'subtab' ) { // Get First Subtab element from subtabs array
$this_subtab_tag = $temp_this_subtab_tag;
$this_subtab = $temp_this_subtab;
break;
}
}
//debuge($this_page, $_REQUEST);
if ( ( isset( $_REQUEST[ 'page' ] ) )
&& ( $this_page == $_REQUEST[ 'page' ] ) ){ // We are inside of this page. Menu item selected.
if ( ( ! isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB NOT selected && Default
//&& ( ! isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab NOT selected
&& ( isset( $this_tab['default'] ) ) && ( $this_tab['default'] )
)
$is_page_selected = true;
if ( ( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB Selected
&& ( ! isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab NOT selected && ! exist || Default
&& ( $_REQUEST[ $this->tags['tab'] ] == $this_tab_tag )
&& ( ( $this_subtab_tag === 0 )
|| ( $this_subtab['default'] )
)
)
$is_page_selected = true;
if ( ( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // TAB Selected
&& ( isset( $_REQUEST[ $this->tags['subtab'] ] ) ) // SubTab Selected
&& ( $_REQUEST[ $this->tags['tab'] ] == $this_tab_tag )
&& ( $_REQUEST[ $this->tags['subtab'] ] == $this_subtab_tag )
)
$is_page_selected = true;
}
if ( $is_page_selected ) // If this page activated, then define Current Page parameters
$this->define_current_page_parameters( $this_tab_tag, $this_tab, $this_subtab_tag, $this_subtab );
return $is_page_selected;
}
/** Define parameters for current selected page
*
* @param type $paramas
*/
private function define_current_page_parameters( $this_tab_tag, $this_tab, $this_subtab_tag, $this_subtab ) {
$this->current_page_params = array(
'tab' => array_merge ( $this_tab, array( 'tag' => $this_tab_tag ) )
, 'subtab' => array_merge ( $this_subtab, array( 'tag' => $this_subtab_tag ) )
);
}
/** Get Header Title (H1) of this selected page
* Firstly check in subtabs, otherwise get from tabs and if not exist then
*
* @return string
*/
private function get_page_header_h1() {
if ( ! empty( $this->current_page_params ) ) {
if ( isset( $this->current_page_params['subtab']['page_title'] ) )
return $this->current_page_params['subtab']['page_title'];
if ( isset( $this->current_page_params['tab']['page_title'] ) )
return $this->current_page_params['tab']['page_title'];
}
return '';
}
/** Get all SubTabs of current opened page Tab
*
* @param string $menu_in_page_tag - Optional. Menu Tag, the same as $this->in_page();
* @return array
*/
private function get_all_sub_tabs_of_selected_tab( $menu_in_page_tag = false ) {
if ($menu_in_page_tag === false )
$menu_in_page_tag = $this->in_page();
$all_sub_tabs_of_selected_tab = self::$nav_tabs[ $menu_in_page_tag ][ $this->current_page_params['tab']['tag'] ]['subtabs'];
return $all_sub_tabs_of_selected_tab;
}
////////////////////////////////////////////////////////////////////////////
// T A B s
////////////////////////////////////////////////////////////////////////////
// Define ------------------------------------------------------------------
/** Define TABS structure.
* General structure of tabs for every plugin menu page.
*/
public function opsd_define_nav_tabs() { // Function executed after creation menu in class OPSD_Admin_Menus
/*
Array (
[opsd-resources] => Array ()
[opsd-settings] => Array
(
[general] => Array
(
[title] => General
[page_title] => General Settings
...
[subtabs] => Array ()
)
[help] => Array
(
[title] => Help
[page_title] =>
...
[subtabs] => Array ()
)
[form] => Array
(
[title] => Form
[hint] => Customizaton of Form Fields
[page_title] => Form Fields
...
[subtabs] => Array
(
[goto-form] => Array
(
[type] => goto-link
[title] => Form Fields
...
[content] => content
[update] => update
)
[goto-content-data] => Array
(
[type] => button
[title] => Save Changes
[form] => opsd_form
...
)
)
)
[payment] => Array
(
[title] => Payments
[hint] => Customizaton of Payment
[page_title] => Payment Gateways
...
[subtabs] => Array
(
[paypal] => Array
(
[type] => subtab
[title] => PayPal
...
)
[sage] => Array
(
[type] => subtab
[title] => Sage
...
)
)
)
)
)
*/
if ( ! isset( self::$nav_tabs[ $this->in_page() ] ) )
self::$nav_tabs[ $this->in_page() ] = array(); // If this page does not exist, then define it.
$current_tab = $this->tabs();
$current_subtabs = array(); // Get Subtabs in separate array.
foreach ( $current_tab as $tab_tag => $tab_array ) {
if ( isset( $tab_array[ 'subtabs' ] ) ) {
$current_subtabs[ $tab_tag ] = $tab_array[ 'subtabs' ]; // Create new Subtabs array
unset( $current_tab[ $tab_tag ][ 'subtabs' ] ); // Detach Subtabs array from Tab array. Its required for do not overwrite subtabs with already exist subtabs in previlosly defined tab.
} else
$current_subtabs[ $tab_tag ] = array();
}
foreach ( $current_tab as $tab_tag => $tab_array ) {
if ( ! isset( self::$nav_tabs[ $this->in_page() ][ $tab_tag ] ) ) { // If this tab ( for exmaple "payment") declared previously, then does not do anything
self::$nav_tabs[ $this->in_page() ][ $tab_tag ] = $current_tab[ $tab_tag ];
self::$nav_tabs[ $this->in_page() ][ $tab_tag ][ 'subtabs' ] = array();
}
if ( isset(self::$nav_tabs[ $this->in_page() ] ) ) {
// Merge subtabs (Ex: PayPal and Sage) and attach to current tab: (Ex: payment)
self::$nav_tabs[ $this->in_page() ][ $tab_tag ][ 'subtabs' ] = array_merge(
self::$nav_tabs[ $this->in_page() ][ $tab_tag ][ 'subtabs' ]
, $current_subtabs[ $tab_tag ]
);
}
}
}
/** Get array of visible TABs
* Tabs that do not hided or disbaled
*
* @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page();
* @return type
*/
private function get_visible_tabs( $menu_in_page_tag ) {
$visible_tabs = array();
foreach ( self::$nav_tabs[ $menu_in_page_tag ] as $tab_tag => $tab ) {
if ( empty( $tab['disabled'] )
&& empty( $tab['hided'] )
) {
$visible_tabs[$tab_tag] = $tab;
}
}
return $visible_tabs;
}
// Showing -----------------------------------------------------------------
/**
*
* @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page();
* @return boolean - true if nav tabs exist and false if does not exist
*/
public function show_tabs_structure( $menu_in_page_tag ) {
// Exit if no Tabs in this page.
if ( empty( self::$nav_tabs[ $menu_in_page_tag ] ) )
return false;
// Exit if tabs hidded or disbaled
$visible_tabs = $this->get_visible_tabs( $menu_in_page_tag );
if ( empty( $visible_tabs ) )
return false;
?><span class="wpdevelop wpdvlp-nav-tabs-container">
<div class="clear"></div><?php
opsd_bs_toolbar_tabs_html_container_start();
do_action( 'opsd_toolbar_top_tabs_before' , $menu_in_page_tag );
$this->show_tabs_line( $menu_in_page_tag ); // T O P T A B S
do_action( 'opsd_toolbar_top_tabs_after' , $menu_in_page_tag );
opsd_bs_toolbar_tabs_html_container_end();
$bottom_tabs = $this->get_all_sub_tabs_of_selected_tab( $menu_in_page_tag );
if ( ! empty( $bottom_tabs ) ) { // S U B T A B S
opsd_bs_toolbar_sub_html_container_start();
$this->show_subtabs_line( $bottom_tabs, $menu_in_page_tag );
opsd_bs_toolbar_sub_html_container_end();
} // Bottom Tabs
?></span><?php
return true;
}
/** Show Top nav TABs line
*
* @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page();
*/
public function show_tabs_line( $menu_in_page_tag ) {
foreach ( self::$nav_tabs[ $menu_in_page_tag ] as $tab_tag => $tab ) {
$css_classes = ( ( isset($tab['css_classes']) ) ? $tab['css_classes'] : '' );
if ( ( isset( $this->current_page_params['tab'] ) ) && ( $this->current_page_params['tab']['tag'] == $tab_tag ) )
$css_classes .= ' nav-tab-active';
if ( ! empty( $tab['position'] ) )
$css_classes .= ' nav-tab-position-' . $tab['position'];
if ( ! empty( $tab['hided'] ) )
$css_classes .= ' hide';
if ( ( isset( $tab['disabled'] ) ) && ( $tab['disabled'] ) )
$css_classes .= ' wpdevelop-tab-disabled';
$tab['css_classes'] = $css_classes;
$tab['link'] = ( ! empty($tab['link']) ? $tab['link'] : $this->get_tab_url( $menu_in_page_tag, $tab_tag ) );
if ( // Recheck active status of default TAB
( isset( $_REQUEST[ $this->tags['tab'] ] ) ) // Some Tab selected
&& ( $_REQUEST[ $this->tags['tab'] ] !== $tab_tag ) // This tag not in URL
&& ( isset($tab['default']) && ( $tab['default'] ) ) // This tab default, need to set it as not defaultm for not showing it selected
)
$tab['default'] = false;
opsd_bs_display_tab( $tab );
}
}
/** Show Sub Menu Lines at the Settings page for Active Tab
*
* @param array $bottom_tabs
* @param string $menu_in_page_tag - Menu Tag, the same as $this->in_page();
*/
public function show_subtabs_line( $bottom_tabs, $menu_in_page_tag ) {
if ( ! empty( $bottom_tabs ) )
foreach ( $bottom_tabs as $tab_tag => $tab ) {
switch ( $tab['type'] ) {
case 'separator': // Separator
?><span class="wpdevelop-submenu-tab-separator-vertical"></span><?php
break;
case 'button': // Button
?><div class="clear-for-mobile"></div><input
type="button"
class="button button-primary opsd_submit_button"
value="<?php echo $tab['title']; ?>"
onclick="if (typeof document.forms['<?php echo $tab['form']; ?>'] !== 'undefined'){ document.forms['<?php echo $tab['form']; ?>'].submit(); } else { opsd_admin_show_message( '<?php echo ' <strong>', __('Error', 'secure-downloads') ,'!</strong> ', __('Form', 'secure-downloads') , ' <strong>' , $tab['form'] , '</strong> ', __('does not exist', 'secure-downloads'); ?>.', 'error', 10000 ); }"
/><?php
break;
case 'html': // HTML
echo $tab['html'];
break;
case 'goto-link':
?><a class="nav-tab wpdevelop-submenu-tab go-to-link"
original-title="<?php echo (empty($tab['hint'])?'':$tab['hint']); ?>"
onclick="javascript:opsd_scroll_to('#<?php echo esc_js( $tab['show_section'] ); ?>' );"
href="javascript:void(0);"><span><?php echo $tab['title']; ?></span></a><?php
break;
default: // Link
$css_classes = ( ( isset($tab['css_classes']) ) ? $tab['css_classes'] : '' );
if ( ! empty($tab['position'] ) )
$css_classes .= ' nav-tab-position-'.$tab['position'];
if ( $tab_tag == $this->current_page_params['subtab']['tag'] )
$css_classes .= ' wpdevelop-submenu-tab-selected';
if ( $tab['disabled'] )
$css_classes .= ' wpdevelop-submenu-tab-disabled';
$tab['css_classes'] = $css_classes;
$tab['link'] = ( ! empty($tab['link']) ? $tab['link'] : $this->get_tab_url( $menu_in_page_tag, $this->current_page_params['tab']['tag'], $tab_tag ) );
$tab['top'] = false;
opsd_bs_display_tab( $tab );
break;
} // End Switch
} // End Bottom Tabs Loop
}
////////////////////////////////////////////////////////////////////////////
// Support
////////////////////////////////////////////////////////////////////////////
/** Get URL of settings page, based on Page Slug and Tab Slug
*
* @param string $page_tag
* @param string $tab_name
* @param string $subtab_name ( Optional )
* @return string - Escaped URL to plugin page.
*/
private function get_tab_url( $page_tag, $tab_name, $subtab_name = false ){
if ( $subtab_name === false )
return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $this->tags['tab'] => $tab_name ), 'admin.php' ) ) );
else
return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $this->tags['tab'] => $tab_name, $this->tags['subtab'] => $subtab_name ), 'admin.php' ) ) );
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,157 @@
<?php /**
* @version 1.1
* @package Any
* @category Load JS and CSS files
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-10-28
*/
abstract class OPSD_JS_CSS {
public $objects = array();
public $type; // css || js
function __construct() {
$this->define();
add_action( 'admin_enqueue_scripts', array( $this, 'registerScripts' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'registerScripts' ) );
add_action( 'opsd_load_js_on_admin_page', array( $this, 'load_js_on_admin_page' ) ); // Load JS. Hook fire only in admin pages of plugin. CLASS: OPSD_Admin_Menus (..\any\class\class-admin-menu.php)
add_action( 'opsd_load_css_on_admin_page', array( $this, 'load_css_on_admin_page' ) ); // Load CSS. Hook fire only in admin pages of plugin. CLASS: OPSD_Admin_Menus (..\any\class\class-admin-menu.php)
}
public function load_css_on_admin_page() {
if ( $this->getType() == 'css' )
$this->load();
}
public function load_js_on_admin_page() {
if ( $this->getType() == 'js' )
$this->load();
}
/** Define all Scripts or Styles here */
abstract public function define();
/** Enqueue Scripts or Styles.
*
* @param type $where_to_load - can be "admin" or "client"
*/
abstract public function enqueue( $where_to_load );
/** Deregister some Conflict scripts from other plugins.
*
* @param type $where_to_load - can be "admin" or "client"
*/
abstract public function remove_conflicts( $where_to_load );
// Define CSS or JavaScript
public function setType($param) {
$this->type = $param;
}
// Get type of this script
public function getType() {
return $this->type;
}
// Add new Style or Script
public function add($param) {
$this->objects[] = $param;
}
private function isLoad( $whereToLoadArray ) {
$is_load = false;
if ( ( is_admin() ) && ( in_array('admin', $whereToLoadArray ) ) )
$is_load = true;
if ( ( ! is_admin() ) && ( in_array('client', $whereToLoadArray ) ) )
$is_load = true;
return $is_load;
}
// Register
public function registerScripts() {
//if ( function_exists( 'wp_dequeue_script' ) )
$this->remove_conflicts( ( is_admin() ? 'admin': 'client' ) );
foreach( $this->objects as $script ) {
if ( $this->isLoad( $script['where_to_load'] ) ) {
if ( $this->getType() == 'css' )
wp_register_style( $script['handle'], $script['src'], $script['deps'], $script['version'] );
else
wp_register_script( $script['handle'], $script['src'], $script['deps'], $script['version'] );
}
}
}
// Load scripts or styles here
public function load(){
$is_load_scripts = true;
$is_load_scripts = apply_filters( 'opsd_is_load_script_on_this_page', $is_load_scripts );
if ( ! $is_load_scripts ) return; // Exist, if on some page we do not need to load scripts
foreach( $this->objects as $num => $script ) {
if ( $this->isLoad( $script['where_to_load'] ) ) {
if ( $this->getType() == 'css' ) {
if ( $script['condition'] === false )
wp_enqueue_style( $script['handle'] );
else {
if (! function_exists('wp_style_add_data') ) { // This function is available only since WordPress 3.6.0 Update
wp_enqueue_style( $script['handle'] );
wp_style_add_data( $script['handle'], 'conditional', $script['condition'] );
} else { // Add additional "dynamic CSS" if the WP version older than 3.6.0 (its function suport since WP 3.3)
if ( ($num-1) > -1 ) { // Its because "wp_add_inline_style" add the CSS to the already added style. So its require that some other simple style was added before
wp_enqueue_style( $this->objects[($num-1)]['handle'] );
wp_add_inline_style( $this->objects[($num-1)]['handle'],
sprintf("<!--[if ".$script['condition']."]>\n" .
"<link rel='stylesheet' id='".$script['handle']."-css' href='". $script['src'] ."?ver=" . $script['version'] . "' type='text/css' media='all' />\n" .
"<![endif]-->\n")
);
}
}
}
} else {
wp_enqueue_script( $script['handle'] );
}
}
}
$this->enqueue( ( is_admin() ? 'admin': 'client' ) );
if ( $this->getType() == 'css' )
do_action( 'opsd_enqueue_style', ( is_admin() ? 'admin': 'client' ) );
if ( $this->getType() == 'js' )
do_action( 'opsd_enqueue_script', ( is_admin() ? 'admin': 'client' ) );
}
}

View File

@@ -0,0 +1,146 @@
/*
Document : admin resources-table
Created on : 2016-08-09, 11:38:06
Author : wpdevelop
Description: Resource Table CSS
*/
/* General Class */
.opsd_resources_table {
}
/* Resources Table */
.opsd_resources_table .table,
.opsd_resources_table .table.widefat {
border: 0px solid #bbb;
box-shadow: 0 0 2px #aaa;
}
.opsd_resources_table table > thead > tr > th {
background-color: #ffffff;
border-bottom: 2px solid #e5e5e5;
}
.wpdevelop.opsd_resources_table table > tfoot > tr > th {
background-color: #ffffff;
border-top: 2px solid #e5e5e5;
}
.opsd_resources_table thead th,
.opsd_resources_table tfoot th {
font-weight:600;
text-align: left;
}
.opsd_resources_table th a,
.opsd_resources_table th a:hover,
.opsd_resources_table th a:focus {
text-decoration: none;
}
.wpdevelop.opsd_resources_table table > tbody > tr.row_selected_color > th,
.wpdevelop.opsd_resources_table table > tbody > tr.row_selected_color > td {
background: #b5d4ef;
border-color: #ccc !important;
}
.opsd_resources_table th a span.glyphicon {
font-size: 0.8em;
font-weight: 400;
padding-left: 2px;
}
.wpdevelop.opsd_resources_table .table > thead > tr > th,
.wpdevelop.opsd_resources_table .table > tbody > tr > th,
.wpdevelop.opsd_resources_table .table > tfoot > tr > th,
.wpdevelop.opsd_resources_table .table > thead > tr > td,
.wpdevelop.opsd_resources_table .table > tbody > tr > td,
.wpdevelop.opsd_resources_table .table > tfoot > tr > td {
vertical-align: middle;
}
/* Labels Colors */
.opsd_resources_table .label {
border: 1px solid #EEEEEE;
box-shadow: 0 0 1px #ddd;
padding: 2px 5px;
white-space: nowrap;
line-height: 2.4em;
}
.opsd_resources_table .label span,
.opsd_resources_table .label a,
.opsd_resources_table .label a:hover{
color:#fff;
text-decoration: none;
}
.opsd_resources_table .label-pending {
background: #FFBB45;
}
.opsd_resources_table .label-approved {
background: #9BE;
}
.opsd_resources_table .label-trash {
background: #D94A48;
color: #fff;
text-shadow: 0 0 1px #E00;
}
.opsd_resources_table .label-success {
}
.opsd_resources_table .label-unknown {
background-color: #999 !important;
}
.opsd_resources_table .label-error {
background-color: #FA773D !important;
}
.opsd_resources_table .payment-label-success {
background-color: #468847 !important;
}
.opsd_resources_table .payment-label-pending {
background-color: #992 !important;
}
.opsd_resources_table .payment-label-unknown {
background-color: #999 !important;
}
.opsd_resources_table .payment-label-error {
background-color: #FA773D !important;
}
.opsd_resources_table .field-currency {
color: #444;
display: inline;
font-size: 15px;
font-weight: 600;
line-height: 1.7em;
height: 26px;
padding:0;
vertical-align: top;
}
.wpdevelop.opsd_resources_table .table > tbody > tr > td select.form-control,
.opsd_resources_table select {
width:auto;
height:2em;
padding: 2px;
border-radius: 0;
}
@media (max-width: 782px) {
.opsd_resources_table th.opsd_hide_mobile,
.opsd_resources_table td.opsd_hide_mobile {
display: none;
}
.opsd_resources_table th.opsd_col_id,
.opsd_resources_table td.opsd_col_id {
width: 4em;
}
.opsd_resources_table th.opsd_col_title,
.opsd_resources_table td.opsd_col_title {
width: 9em;
}
.opsd_resources_table .field-currency {
line-height: 2.1em;
}
#wpbody .opsd_resources_table select {
height:32px;
}
}
@media (max-width: 600px) {
.opsd_resources_table th.opsd_hide_mobile_xs,
.opsd_resources_table td.opsd_hide_mobile_xs {
display: none;
}
}

View File

@@ -0,0 +1,358 @@
/*
Document : admin-opsd-listing
Created on : 09.02.2014, 11:38:06
Author : wpdevelop
Description: Listing Table CSS
*/
/* Header */
.opsd-listing-header {
background: #e4e4e4; /* for non-css3 browsers */
border: 1px solid #C6C6C6;
border-bottom-color: #CCC;
border-radius: 4px 4px 0 0;
-moz-border-radius: 4px 4px 0 0;
-webkit-border-radius: 4px 4px 0 0;
-ms-border-radius: 4px 4px 0 0;
color: #333;
font-size: 12px;
font-weight: 600;
margin: 0;
padding: 2px 0px;
text-shadow: 0 1px 1px #F5F5F5;
}
/* Row */
.opsd-listing-row {
border: 1px solid #C6C6C6;
border-top: none;
margin: 0px;
padding: 0px;
}
.opsd-listing-row.row_alternative_color.row,
.opsd-listing-row.row_alternative_color {
background: #F7F7F7;
}
.opsd-listing-row.row.row_selected_color {
background: #9cf;
border-color: #aaa !important;
}
.opsd-listing-row.opsd-listing-last_row {
border-radius: 0 0 4px 4px;
-moz-border-radius: 0 0 4px 4px;
-webkit-border-radius: 0 0 4px 4px;
-ms-border-radius: 0 0 4px 4px;
}
/* Columns */
.opsd-listing-collumn {
margin: 5px 0px 2px;
}
.opsd-listing-collumn .field-id {
color: #999;
font-size: 10px;
font-weight: 600;
text-align: right;
/* background-color: #777;
border: 1px solid #FFF;
border-radius: 10px 10px 10px 10px;
box-shadow: 0 0 2px #888;
color: #EEE;
font-size: 9px;
font-weight: 600;
padding: 2px 4px;
text-shadow: 0 0 3px #333;*/
}
.opsd-listing-collumn .field-id span.label {
border-radius: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
background: #bbb;
color: #fff;
margin: 0;
padding: 2px 5px;
background: #888;
border:none;
line-height:2.8em;
}
.opsd-listing-collumn.field-system-info {
font-size: 9px;
font-style: italic;
line-height: 1.2em;
text-align: left;
text-shadow: 0 -1px 0 #eee;
white-space: nowrap;
padding: 2em 5px 0;
text-align: right;
color: #777;
}
.opsd-listing-collumn.field-system-info .field-creation-date {
font-weight: 600;
}
/* Checkbox */
.opsd-listing-collumn .field-checkbox {
vertical-align: middle;
}
/* Main Content */
.opsd-listing-collumn.field-content,
.opsd-listing-collumn .standard-content-form {
text-align: left;
word-wrap: break-word;
line-height: 1.7em;
}
/* Data Titles style - Yellow Values*/
.opsd-listing-collumn .fieldvalue {
background: #FE9;
color: #333;
font-size: 0.9em;
font-weight: 400;
margin: 0 3px 0 0;
padding: 2px 3px;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
/* text-shadow: 0 1px 1px #EEE;*/
}
/* Labels Colors */
.opsd-listing-collumn .label {
border: 1px solid #EEEEEE;
box-shadow: 0 0 1px #ddd;
padding: 2px 5px;
white-space: nowrap;
line-height: 2.4em;
}
.opsd-listing-collumn .label span,
.opsd-listing-collumn .label a,
.opsd-listing-collumn .label a:hover{
color:#fff;
text-decoration: none;
}
.opsd-listing-collumn .label-pending {
background: #FFBB45;
}
.opsd-listing-collumn .label-approved {
background: #9BE;
}
.opsd-listing-collumn .label-trash {
background: #D94A48;
color: #fff;
text-shadow: 0 0 1px #E00;
}
.opsd-listing-collumn .label-success {
}
.opsd-listing-collumn .label-unknown {
background-color: #999 !important;
}
.opsd-listing-collumn .label-error {
background-color: #FA773D !important;
}
.opsd-listing-collumn .payment-label-success {
background-color: #468847 !important;
}
.opsd-listing-collumn .payment-label-pending {
background-color: #992 !important;
}
.opsd-listing-collumn .payment-label-unknown {
background-color: #999 !important;
}
.opsd-listing-collumn .payment-label-error {
background-color: #FA773D !important;
}
/* Pagination */
.opsd-pagination .button{
box-shadow: none;
height: 32px;
line-height: 30px;
margin: 0 0 5px;
padding: 0 15px;
}
.wpdevelop.opsd-pagination .container-fluid .row .btn-toolbar .btn-group > .button.disabled {
box-shadow: none !important;
}
.wpdevelop.opsd-pagination .btn-toolbar .btn-group > .button.active {
box-shadow: 0 1px 5px -4px rgba(0, 0, 0, 0.5) inset;
font-weight: 600;
}
@media (max-width: 782px) {
.opsd-listing-header .opsd-listing-collumn {
font-size: 1.2em;
line-height: 2.2em;
margin:0;
}
.opsd-listing-header .opsd-listing-collumn input[type=checkbox] {
margin:-4px 0 0;
}
.opsd-listing-collumn.field-system-info {
padding:0 5px;
}
/* Pagination */
.opsd-pagination .button {
font-size: 14px;
height: 36px;
line-height: 34px;
margin: 0 0 5px;
padding: 0 16px;
}
}
/* C U S T O M ****************************************************************/
/* New Label */
.opsd-listing-collumn.new-label {
margin: 5px 0 0 -32px;
position: absolute !important;
}
.opsd-listing-collumn.new-label a{
font-size:13px;
}
.opsd-listing-collumn.new-label a i.glyphicon{
color:#8ac;
}
/* Dates */
.opsd-listing-collumn.field-dates .field-securedownloads-date,
.opsd-listing-collumn.field-dates .field-securedownloads-date:hover {
background: none repeat scroll 0 0 #FFBB45;
border: 1px solid #EEE;
border-radius: 5px 5px 5px 5px;
box-shadow: 0 0 1px #CCC;
color: #FFF;
font-weight: 600;
padding: 4px 10px 4px;
text-decoration: none;
text-shadow: 0 0px 0 #CCC;
white-space: nowrap;
font-size: 0.85em;
line-height: 2.5em;
}
.opsd-listing-collumn.field-dates .field-securedownloads-date.approved,
.opsd-listing-collumn.field-dates .field-securedownloads-date.approved:hover {
background: none repeat scroll 0 0 #9BE;
}
.opsd-listing-collumn.field-dates .field-securedownloads-time {
color: #555;
text-decoration: none;
text-shadow: 0 0 1px #AAA;
}
.opsd-listing-collumn.field-dates .date_tire {
font-size: 17px;
font-weight: 600;
}
.opsd-listing-collumn.field-dates .securedownloads_dates_small,
.opsd-listing-collumn.field-dates .securedownloads_dates_full {
line-height: 24px;
}
.opsd-listing-collumn.field-dates .date_from_dif_type {
color: #FFF;
text-shadow: 0 -1px 0 #BBB;
}
/* Actions buttons */
.opsd-listing-collumn.field-action-buttons {
padding-right: 2px;
}
.opsd-listing-collumn.field-action-buttons a.button {
margin:0 5px 5px 0;
}
.opsd-listing-collumn .glyphicon.red_icon_color {
color:#d54e21;
}
.opsd-listing-collumn .opsd-buttons-separator {
margin-right: 15px;
}
.opsd_free .opsd-listing-collumn .opsd-buttons-separator {
margin-right: 0px;
}
/* Cost Group */
.opsd-listing-collumn.field-action-buttons .cost-fields-group {
float:left;
}
.opsd-listing-collumn.field-action-buttons .cost-fields-group .field-currency {
color: #444;
display: inline;
font-size: 15px;
font-weight: 600;
line-height: 26px;
height: 26px;
padding:0;
vertical-align: top;
}
.opsd-listing-collumn.field-action-buttons .cost-fields-group.control-group .btn-toolbar .input-group > input[type="text"].field-securedownloads-cost {
display: inline-block;
margin: 0 5px 5px 0;
width: 75px;
font-weight: 600;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
.opsd-listing-collumn.field-action-buttons select.opsd-select-locale {
display: none;
margin: 0 5px 5px 0;
}
.opsd_free .opsd-listing-collumn.field-system-info {
padding:0 5px;
margin-top:-0.5em;
}
/* Columns customizations - labels header */
#listing_visible_opsd .opsd-listing-header .opsd_column_3 {
white-space: nowrap;
}
.label_resource_not_exist {
color: #000;
font-weight: 600;
text-shadow: 0 1px 0 #59D;
text-transform: none;
}
.opsd-listing-row .securedownloads_row_modification_element {
display: none;
clear: both;
width: 100%;
}
.opsd-listing-row .securedownloads_row_modification_element_changing_resource {
height: auto;
}
.opsd-listing-row .securedownloads_row_modification_element .btn-save-cost,
.opsd-listing-row .securedownloads_row_modification_element.securedownloads_edit_note a,
.opsd-listing-row .securedownloads_row_modification_element select{
float: left;
margin: 0 0 5px 5px;
}
#hided_boking_modifications_elements,
.hided_boking_modifications_elements { /* FixIn:5.4.5.1 */
display: none;
}
@media (max-width: 782px) {
/* New Label */
.opsd-listing-collumn.new-label {
margin: 7px 0 0 -26px;
position: absolute !important;
}
/* Dates */
.opsd-listing-collumn .field-id.text-center,
.opsd-listing-collumn .securedownloads-labels.text-center,
.opsd-listing-collumn.securedownloads-dates.text-center{
text-align: left;
}
.opsd-listing-collumn.field-action-buttons .control-group a.button {
height: 34px;
}
/* Cost Group */
.opsd-listing-collumn.field-action-buttons .cost-fields-group .field-currency {
line-height: 34px;
height: 34px;
font-size: 18px;
}
.opsd-listing-collumn.field-action-buttons .cost-fields-group.control-group .btn-toolbar .input-group > input[type="text"].field-securedownloads-cost {
padding: 2px 5px;
}
}

View File

@@ -0,0 +1,242 @@
/**
* @version 1.0
* @package: Tabs
* @category: Admin UI
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015.04.10
*/
/* Top Tab Menu ***************************************************************/
.wpdvlp-top-tabs {
margin:0;
position: relative;
width: auto;
}
.wpdvlp-top-tabs .wpdvlp-tabs-wrapper {
height: 28px;
margin-bottom: -1px;
width: 100%;
}
.wpdvlp-top-tabs .nav-tabs {
float: left;
margin-left: 0;
padding-left: 0px;
/* border-bottom: none !important;*/
border-bottom: 1px solid #CCC;
width: 100%;
}
.wpdvlp-top-tabs .nav-tab {
border-radius: 3px 3px 0 0;
-moz-border-radius: 3px 3px 0 0;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
border-color: #D5D5D5 #D5D5D5 #BBC #D5D5D5;
border-style: solid;
border-width: 1px 1px 0;
border-bottom: none;
display: inline-block;
background: none repeat scroll 0 0 #F4F4F4;
background: #DFDFDF;
color: #464646;
font-weight: 600;
font-size: 13px;
text-decoration: none;
text-shadow: 0 1px 0 #F1F1F1;
line-height: 18px;
padding: 4px 14px 6px;
padding: 5px 15px 5px;
margin: 0 5px 0 0;
}
.wpdvlp-top-tabs .pull-right .nav-tab {
margin: 0 0 0 5px;
}
.wpdvlp-top-tabs a.nav-tab:hover,
.wpdvlp-top-tabs a.nav-tab:visited,
.wpdvlp-top-tabs a.nav-tab:link ,
.wpdvlp-sub-tabs a.nav-tab:hover,
.wpdvlp-sub-tabs a.nav-tab:visited,
.wpdvlp-sub-tabs a.nav-tab:link {
text-decoration: none;
outline: none;
}
/* IE6 */
* html .wpdvlp-top-tabs .nav-tab {
padding: 4px 14px 5px 32px;
}
.wpdvlp-top-tabs a.nav-tab:hover {
color: #D54E21 !important;
background-color: #E7E7E7 !important;
}
.wpdvlp-top-tabs .nav-tab-active,
.wpdvlp-top-tabs a.nav-tab-active:hover,
.wpdvlp-top-tabs a.nav-tab-active:focus {
border-color: #777;
border-bottom-color: #AAB;
background: none repeat scroll 0 0 #7A7A88;
text-shadow: 0 0px 0 #111;
border-width: 1px;
color: #FFF;
}
.wpdvlp-top-tabs a.nav-tab-active:hover,
.wpdvlp-top-tabs a.nav-tab-active:focus {
color: #FFF !important;
background: none repeat scroll 0 0 #7A7A88 !important;
}
.wpdvlp-top-tabs .nav-tab-position-right {
float:right;
margin: 0 0 0 5px;
}
/* Sub Menu *******************************************************************/
.wpdvlp-sub-tabs {
height: auto;
clear: both;
border: 1px solid #BBC;
border-top: none;
-moz-border-radius: 0px 0px 3px 3px;
-moz-box-shadow: 0 1px 1px #DDD;
-webkit-border-radius: 0px 0px 3px 3px;
-webkit-box-shadow: 0 1px 1px #DDD;
border-radius: 0px 0px 3px 3px;
box-shadow: 0 1px 1px #DDD;
background: #EEE;
margin: 0;
padding: 5px;
}
.wpdvlp-sub-tabs .wpdvlp-tabs-wrapper {
height: auto;
margin-bottom: -1px;
width: 100%;
}
.wpdvlp-sub-tabs .nav-tabs {
border: none;
width: auto;
height: auto;
padding: 0;
margin: 0;
}
.wpdvlp-sub-tabs .nav-tabs .nav-tab {
border: 1px solid #bbb;
background: #F5F5F5;
color: #777;
font-weight: 600;
font-size:13px;
height: 18px;
line-height: 16px;
padding: 6px 10px 4px;
margin: 5px 2px -4px;
border-bottom: none;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
box-sizing: content-box;
}
.wpdvlp-top-tabs .nav-tabs .nav-tab input[type="checkbox"],
.wpdvlp-sub-tabs .nav-tabs .nav-tab input[type="checkbox"] {
margin: 0 0 0 8px !important;
vertical-align: middle;
}
.wpdvlp-sub-tabs .nav-tabs .nav-tab.wpdevelop-submenu-tab-selected,
.wpdvlp-sub-tabs .nav-tabs .nav-tab.wpdevelop-submenu-tab-selected:hover {
border-color: #777;
border-bottom-color: #AAB;
text-shadow: 0 0px 0 #111;
border-width: 1px;
color: #FFF !important;
background: none repeat scroll 0 0 #7A7A88 !important;
}
.wpdvlp-top-tabs .nav-tabs .nav-tab.wpdevelop-tab-disabled,
.wpdvlp-sub-tabs .nav-tabs .nav-tab.wpdevelop-submenu-tab-disabled {
color: #bbb;
text-shadow: 0 -1px 1px #fff;
}
.wpdvlp-top-tabs .nav-tabs .nav-tab.nav-tab-active.wpdevelop-tab-disabled,
.wpdvlp-sub-tabs .nav-tabs .nav-tab.wpdevelop-submenu-tab-selected.wpdevelop-submenu-tab-disabled {
color: #555 !important;
text-shadow: 0 0 1px #aaa;
}
.wpdvlp-sub-tabs .nav-tabs .nav-tab.go-to-link,
.wpdvlp-sub-tabs .nav-tabs .nav-tab.go-to-link:hover,
.wpdvlp-sub-tabs .nav-tabs .nav-tab.go-to-link:active {
box-shadow: 0 0 0;
font-weight: 400;
border:none;
background: transparent !important;
margin:0 0 -4px;
box-shadow: none;
}
.wpdvlp-sub-tabs .nav-tabs .nav-tab.go-to-link span {
border-bottom: 1px dashed;
padding:0 2px;
}
.wpdvlp-sub-tabs .opsd_submit_button {
float:right;
margin:0px 5px 0px 0px;
}
.wpdvlp-sub-tabs .wpdevelop-submenu-tab-separator-vertical {
-moz-box-shadow: 1px 0px 0px #FEFEFE;
-webkit-box-shadow: 1px 0px 0px #FEFEFE;
box-shadow: 1px 0px 0px #FEFEFE;
border-right: #BBB solid 1px;
border-left: #CCC solid 1px;
background: none;
color: #777;
padding: 5px 0px 5px;
margin: 10px 15px 0px 10px;
}
.clear-for-mobile {
display:none;
}
/* iPad mini and all iPhones and other Mobile Devices */
@media (max-width: 782px) {
/* Settings Top TABS */
.wpdvlp-top-tabs .nav-tab {
padding: 10px 15px 5px;
padding: 8px 15px 8px;
font-size: 1.2em;
}
.wpdvlp-top-tabs .nav-tab .nav-tab-text {
display:none;
}
.wpdevelop-submenu-tab.nav-tab {
border-radius: 0 !important;
-moz-border-radius:0 !important;
-webkit-border-radius:0 !important;
display: block;
float: none;
width: auto;
clear:both;
vertical-align: middle !important;
border-bottom: 1px solid #bbb !important;
margin:-1px 0 0 !important;
padding:0px 10px !important;
height:3em !important;
line-height:3em !important;
}
.wpdevelop-submenu-tab-separator-vertical {
display:none;
}
.wpdevelop-submenu-tab.go-to-link {
border-bottom: none !important;
width:auto;
}
.clear-for-mobile {
clear:both;
width:100%;
height:10px;
display:block;
}
.wpdevelop-submenu-tab input[type="checkbox"] {
margin: -4px 0 0 8px !important
vertical-align: middle !important;
padding:0px !important;
}
}

View File

@@ -0,0 +1,589 @@
/**
* @version 1.0
* @package: Admin Panel
* @category: Admin UI
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-04-11
*/
/* Admin Content Pages */
/* Top Header at the page */
.opsd_page h2.opsd_header {
color: #595959;
font-size: 2em;
line-height: 2em;
padding:0;
text-shadow: 0 0 1px #aaaaaa;
margin-bottom:10px;
}
.opsd_page .wpdevelop label{
font-weight: 400;
}
.opsd_page .wpdevelop label.opsd-required{
font-weight: 600;
}
.opsd_page .wpdevelop optgroup {
font-weight: 600;
}
.opsd_page .wpdevelop .visibility_container {
display:none;
}
.opsd_page .wpdevelop .opsd-no-margin {
margin:0;
}
.opsd_page .wpdevelop .opsd-no-padding {
padding:0;
}
.wpdevelop a.button:focus,
.wpdevelop a.button:hover {
text-decoration: none;
}
/* Support CSS Classes **/
.wpdevelop .visible_items,
.visible_items {
display: block;
}
.wpdevelop .hidden_items,
.hidden_items {
display: none;
}
/* M E S S A G E S - Backward compatibility - For showing correctly messages in WP 4.0 */
.opsd_page .notice {
background: #fff;
border-left: 4px solid #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
margin: 5px 15px 2px;
padding: 1px 12px;
}
.opsd_page .notice-success,
.opsd_page div.updated {
border-left-color: #46b450;
}
.opsd_page div.notice-warning {
border-left-color: #ffb900;
}
.opsd_page .notice-error,
.opsd_page div.error {
border-left-color: #dc3232;
}
.opsd_page .notice-info {
border-left-color: #00a0d2;
}
/* Messages that show at top of admin panel pages */
.opsd_page div.opsd_inner_message {
padding:10px;
/* Overide position and style of Updated Message. If in new WP updates this meesage showing incorrectly, remove this code */
position: absolute;
display: inline;
z-index: 10000;
width: 98%;
margin: 3px 0 0;
top: 5px;
left: 0;
padding: 12px;
box-sizing: border-box;
min-height:1em;
height:auto;
/* From WordPress 4.4.1 */
/*
border-left: 4px solid #fff;
background: #fff none repeat scroll 0 0;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
*/
}
/* From WordPress 4.4.1 */
.opsd_page div.opsd_inner_message a.close,
.opsd_page div.opsd_inner_message a.close:hover,
.opsd_page div.opsd_inner_message a.close:focus{
font-size: 18px;
float: right;
text-decoration: none;
}
/* Form Messages */
.wpdevelop .alert.opsd-near-field-message {
height: auto;
font-size: 0.9em;
background-image: none;
}
/* Alerts & Help messages */
.opsd-info-message,
.opsd-error-message,
.opsd-success-message,
.opsd-help-message{
display: block;
margin: 10px 0;
padding: 5px 10px;
font-weight: 400;
text-align: center;
color:#777;
background-color: #faf8f8;
/* border: 1px solid #E6DB55;*/
border: 2px dashed #bbb;
border-radius: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
line-height: 1.9em;
font-size: 1em;
padding: 5px 10px !important;
width: auto !important;
box-sizing: padding-box;
-moz-box-sizing: padding-box;
-webkit-box-sizing: padding-box;
}
.opsd-help-message {
background-color: #FFFDFD;
text-align: left;
}
.opsd-error-message {
background-color: #FFEEEE;
border-color: #FFBBBB;
}
.opsd-success-message {
background-color: #F5FFF0;
border-color: #AAEEAA;
}
.opsd-demo-alert-not-allow {
color: #AA4400;
font-size: 1.1em;
font-weight: 400;
text-shadow: 0 -1px 0 #FFEEEE;
}
.opsd_inner_message {
margin-bottom: 25px !important;
}
.opsd_inner_message .close{
float: right;
font-size: 18px;
}
.opsd_page div.opsd_outer_message {
position: relative;
display: block;
margin: 5px 0 15px !important;
}
.alert.alert-block {
border:2px dashed;
}
.message {
border-left-width: 3px solid #f90;
clear: both;
display: block;
position: relative;
text-align: left;
}
/* Internal Settings Message */
.opsd-settings-notice {
background: #ffffff;
border-left: 4px solid #fff;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
margin: 5px 0 2px 0;
padding: 1px 12px;
line-height: 2.5em;
text-align:left;
}
.opsd-settings-notice.notice-success {
border-left-color: #46b450;
}
.opsd-settings-notice.notice-success.notice-alt {
background-color: #ecf7ed;
}
.opsd-settings-notice.notice-warning {
border-left-color: #ffb900;
}
.opsd-settings-notice.notice-warning.notice-alt {
background-color: #fff8e5;
}
.opsd-settings-notice.notice-error {
border-left-color: #dc3232;
}
.opsd-settings-notice.notice-error.notice-alt {
background-color: #fbeaea;
}
.opsd-settings-notice.notice-info {
border-left-color: #00a0d2;
}
.opsd-settings-notice.notice-info.notice-alt {
background-color: #e5f5fa;
}
/* Modal Content for popup windows ********************************************/
.opsd_popup_modal {
display: none;
}
/* Sort Table */
table.opsd_sort_table {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.opsd_sort_table thead th {
padding:8px 0;
text-align: center;
font-weight: 600;
font-size:1em;
color:#555 !important;
}
.opsd_sort_table tfoot th {
padding:10px;
}
.opsd_sort_table .widefat th.sort,
.opsd_sort_table .widefat td.sort {
width: 30px;
padding-top:4px;
padding-left:4px;
}
.opsd_sort_table .widefat td.sort::before{
color: #aaa;
content: "\f333";
display: inline-block;
font-family: dashicons;
font-size: 20px;
font-style: normal;
font-weight: 400;
height: 20px;
line-height: 1;
text-align: center;
text-decoration-color: inherit;
text-decoration-line: inherit;
text-decoration-style: inherit;
vertical-align: top;
width: 20px;
padding:4px 0 0 2px;
}
.opsd_sort_table .widefat td.sort span.glyphicon {
vertical-align: middle;
}
.opsd_sort_table .widefat td {
padding:0;
}
.opsd_sort_table .widefat th input[type=text],
.opsd_sort_table .widefat td input[type=text]{
width:100%;
margin:0;
padding-left:5px;
height: 36px;
}
.opsd_sortable_table.widefat {
background:#FAFAFA;
}
.opsd_sortable_table.widefat td.border_bottom {
border-bottom: 1px solid #ddd;
}
.opsd_sortable_table td input[type=text]{
border-radius: 0;
}
/* Color Picker */
.opsd_page .wpdevelop .wp-picker-container .wp-color-result,
.opsd_sortable_table td .wp-picker-container .wp-color-result {
height: 24px;
clear:both;
}
.opsd_sortable_table td .opsd-field-colors {
padding:2px 10px 2px;
border:1px solid #ccc;
font-weight: 600;
font-size:16px;
border-radius:3px;
-moz-border-radius:3px;
-webkit-border-radius:3px;
vertical-align: middle;
}
/* Settings table customization */
.opsd_page .form-table th,
.opsd_page .form-table td {
padding:10px 0;
}
.form-table th label {
line-height: 2em;
vertical-align: middle;
}
/* Dismiss button for Welcome Page Panel *************************************/
.opsd-panel-dismiss {
position: absolute;
top: 5px;
right: 10px;
padding: 8px 3px;
font-size: 13px;
text-decoration: none;
line-height: 1;
outline: 0 none;
cursor: pointer;
}
.opsd-panel-dismiss:before {
content: ' ';
position: absolute;
left: -12px;
width: 10px;
height: 100%;
background: url('../../../../../wp-admin/images/xit.gif') 0 7% no-repeat;
}
.opsd-panel-dismiss:hover:before {
background-position: 100% 7%;
}
/* SORTED Support Styles and Tricks *******************************************/
.opsd_mobile_legend {
display:none;
}
/* Align blocks */
.opsd-align-right {
float: right !important;
}
.opsd-align-left {
float: left !important;
}
/* Align text */
.opsd-text-right {
text-align: right !important;
}
.opsd-text-left {
text-align: left !important;
}
.opsd-text-center {
text-align: center !important;
}
.opsd-text-justify {
text-align: justify !important;
}
.clear-line {
clear:both;
width:100%;
}
/* Trick - Fix HEIGHT for the container with FLOAT elements inside */
.clearfix-height:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
.clearfix-height {
display: inline-block;
}
html[xmlns] .clearfix-height {
display: block;
}
html[xmlns] .clearfix-height.hidden_items {
display: none;
}
* html .clearfix-height {
height: 1%;
}
/* Sortable table */
.opsd_sortable_table thead th {
padding:10px 0;
font-weight: 600;
}
.opsd_sortable_table tfoot th {
padding:10px;
}
.opsd_sortable_table .widefat th.sort,
.opsd_sortable_table .widefat td.sort {
width:30px;
}
.opsd_sortable_table .widefat td.sort::before{
color: #aaa;
content: "\f333";
display: inline-block;
font-family: dashicons;
font-size: 20px;
font-style: normal;
font-weight: 400;
height: 20px;
line-height: 1;
text-align: center;
text-decoration-color: inherit;
text-decoration-line: inherit;
text-decoration-style: inherit;
vertical-align: top;
width: 20px;
padding:4px 0 0 2px;
}
.branch-3-5 .opsd_sortable_table .widefat td.sort::before,
.branch-3-6 .opsd_sortable_table .widefat td.sort::before,
.branch-3-7 .opsd_sortable_table .widefat td.sort::before {
content: "=";
}
.opsd_sortable_table .widefat td {
padding:0;
}
.opsd_sortable_table .widefat th input[type=text],
.opsd_sortable_table .widefat td input[type=text]{
width:100%;
margin:0;
padding-left:5px;
}
/* Hack to fix checkbox height in Firefox, otherwise sometimes, there exist weird artefact */
@-moz-document url-prefix() {
.opsd_page input[type='checkbox'] {
/*height: auto;*/ /* FixIn: 1.1.1.1 */
}
.opsd_page input[type='radio'] {
/*height: auto;*/ /* FixIn: 1.1.1.1 */
/*height: 32px;*/
}
}
/* Ajax loading icon */
.opsd_ajax_icon {
font-size: 9px;
margin: 0px 5px 5px 5px;
line-height: 1em;
vertical-align: middle;
}
/* Rotate Icons for Loading ***********************************************/
.opsd_spin {
-webkit-animation: spin 2s infinite linear;
-moz-animation: spin 2s infinite linear;
-o-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
}
@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
}
}
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
}
}
@-o-keyframes spin {
0% {
-o-transform: rotate(0deg);
}
100% {
-o-transform: rotate(359deg);
}
}
@keyframes spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
.opsd_rotate-90 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
.opsd_rotate-180 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2);
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
transform: rotate(180deg);
}
.opsd_rotate-270 {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-o-transform: rotate(270deg);
transform: rotate(270deg);
}
.opsd_flip-horizontal {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);
-webkit-transform: scale(-1, 1);
-moz-transform: scale(-1, 1);
-ms-transform: scale(-1, 1);
-o-transform: scale(-1, 1);
transform: scale(-1, 1);
}
.opsd_flip-vertical {
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);
-webkit-transform: scale(1, -1);
-moz-transform: scale(1, -1);
-ms-transform: scale(1, -1);
-o-transform: scale(1, -1);
transform: scale(1, -1);
}
/******************************************************************************/
/* iPad mini and all iPhones and other Mobile Devices */
@media (max-width: 782px) {
.opsd_mobile_legend {
display:inline;
font-size: 14px;
font-weight: 400;
float: left;
line-height: 1.3em;
}
.opsd_mobile_legend.clear{
float:none;
display:block;
}
.wpdevelop .hide-sm {
display:none;
}
/* Messages that show at top of admin panel pages */
.opsd_page div.opsd_inner_message {
/* Overide position and style of Updated Message. If in new WP updates this meesage showing incorrectly, remove this code */
margin: 20px 0 25px 10px;
position: fixed;
top: 32px;
width: 96%;
padding: 10px 12px;
min-height: 1em;
height: auto;
}
}
@media (max-width: 480px) {
.wpdevelop .hide-xs {
display:none;
}
}
/* Support new fonts in WP 4.6 */ /* FixIn: 6.2.2.4 */
.wpdevelop .label,
.wpdevelop strong {
font-weight: 600;
}
.wpdevelop [class^="icon-"] {
margin-top: 2px;
}
.wpdevelop .button [class^="icon-"] {
margin-top: 3px;
}

View File

@@ -0,0 +1,441 @@
/**
* @version 1.1
* @package: Tabs
* @category: Admin UI
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-10-29
*/
/* DropDown Selectbox */
.wpdevelop .btn-group.open .dropdown-toggle {
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.125) inset;
background: #ccc;
}
/* Drop Down Menu */
.wpdevelop ul.dropdown-menu {
display: none;
}
.wpdevelop .dropdown-menu li {
padding:0;
margin:0;
}
.wpdevelop .dropdown-menu li.dropdown-header {
padding:0 15px;
color: #999;
font-size: 0.8em;
font-style: italic;
font-weight: 600;
}
.wpdevelop .dropdown-menu > .disabled > a,
.wpdevelop .dropdown-menu > .disabled > a:focus,
.wpdevelop .dropdown-menu > .disabled > a:hover {
color:#ccc;
}
.wpdevelop .dropdown-menu > li > a,
.wpdevelop .dropdown-menu a {
clear: both;
display: block;
font-weight: 400;
padding:5px 15px;
white-space: nowrap;
font-size:13px;
line-height: 18px;
}
.wpdevelop .dropdown-menu li > a:hover,
.wpdevelop .dropdown-menu li.active > a,
.wpdevelop .dropdown-menu li.active > a:hover {
background: #08c;
color: #fff;
text-decoration-color: -moz-use-text-color;
text-decoration-line: none;
text-decoration-style: solid;
}
/* radio button or checbox togther with selctbox as option in dropdown list */
.wpdevelop .dropdown-menu li .btn-toolbar .input-group {
margin:2px 5px 4px 5px;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group .input-group-addon {
background: none;
border: none;
box-shadow: none;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group .input-group-addon input {
margin:0 5px 0 0;
vertical-align: middle;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group .input-group-addon label {
color: #444;
margin: 0;
vertical-align: middle;
line-height: 16px;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group select {
border-radius:0px;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
}
/* button group in drop down list*/
.wpdevelop .dropdown-menu li .btn-toolbar .btn-group {
float: right;
margin: 0 5px;
}
.wpdevelop .dropdown-menu li .btn-toolbar .btn-group a.button {
clear:none;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group.text-group {
display:block;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group.text-group .input-group-addon {
text-align: left;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group.text-group .dropdown-menu-text-element{
box-sizing: padding-box;
float: left;
font-size: 11px;
padding: 0 0 0 15px;
width: 50%;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group.text-group .dropdown-menu-text-element.dropdown-menu-text-element-count-1 {
width: 100%;
}
.wpdevelop .dropdown-menu li .btn-toolbar .input-group.text-group .dropdown-menu-text-element input[type=text] {
font-size: 12px;
width: 100%;
}
/* Containers in Toolbars */
.wpdevelop .visibility_container .tab-bottom {
-moz-border-bottom-colors: none;
-moz-border-image: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: none repeat scroll 0 0 #EEE;
border-color: #BBC;
border-width: 1px;
border-style: dashed solid solid;
border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-radius: 0 0 5px 5px;
-ms-border-radius: 0 0 5px 5px;
box-shadow: 0 0 1px #DDD;
padding: 0px 7px;
position: absolute;
margin-top: 4px;
}
.wpdevelop .visibility_container .tab-bottom a {
color:#777;
}
.wpdevelop .visibility_container .control-group {
float:left;
margin-right:15px;
margin-top:8px;
min-height: 29px;
}
.wpdevelop .control-group .dropdown-toggle label.label_in_filters {
font-weight: 600;
}
/* Buttons Group */
.wpdevelop .btn-group a.button:focus,
.wpdevelop .btn-group a.button:hover,
.wpdevelop .form-group .input-group a.button:focus,
.wpdevelop .form-group .input-group a.button:hover{
text-decoration: none;
}
.wpdevelop .control-group .btn-group > .button{
float: left;
margin:0 0 0 -1px;
position: relative;
}
.wpdevelop .control-group .btn-group > .button.active {
background-color: #E6E6E6;
background-image: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
color: rgba(0, 0, 0, 0.5);
outline: 0 none;
border-color: #CCCCCC;
}
/* control-group | btn-group */
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text'],
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button {
height: 34px;
line-height: 1.42857143;
height: 28px;
}
.wpdevelop .control-group .btn-toolbar .input-group > select,
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text'],
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon {
padding: 4px 12px;
font-size: 13px;
box-shadow: inset 0 0px 0 #fff,0 1px 0 rgba(0,0,0,.08);
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon {
text-shadow: 0 1px 1px #fff;
background-color: #eee;
color: #444;
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon > input {
vertical-align: bottom;
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button {
line-height: 26px;
font-size: 13px;
vertical-align: middle;
padding: 0 10px -1px;
}
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text'] {
padding: 4px 4px 4px 8px;
height: 28px;
}
.wpdevelop .control-group .btn-toolbar .input-group > select {
height: 28px;
line-height: 22px;
padding: 0 12px;
font-size: 13px;
}
.wpdevelop .control-group .btn-toolbar .input-group > select option:disabled {
color: #bbb;
}
.wpdevelop .control-group .btn-toolbar .input-group .input-group-btn .button {
box-shadow: 0 0 0 #ffffff inset, 0 1px 0 rgba(0, 0, 0, 0.08);
}
.wpdevelop .control-group-text {
float:left;
margin-right:10px;
height:28px;
line-height:28px;
}
.wpdevelop .btn-toolbar .input-group > .input-group-btn .button.disabled,
.wpdevelop .btn-toolbar .btn-group > .button.disabled,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button.disabled,
.wpdevelop .control-group .btn-toolbar .btn-group > .button.disabled {
box-shadow: 0 1px 0 #cfcfcf !important;
}
.wpdevelop .btn-toolbar .input-group > .input-group-btn .button.active,
.wpdevelop .btn-toolbar .btn-group > .button.active,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button.active,
.wpdevelop .control-group .btn-toolbar .btn-group > .button.active {
transform: none;
border-color: #ccc;
}
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text'],
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon,
.wpdevelop .control-group .btn-toolbar .btn-group > .button,
.wpdevelop .control-group .btn-toolbar .btn-group > input[type=text],
.wpdevelop .control-group .btn-toolbar .btn-group > select {
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text']:first-child,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn:first-child .button,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon:first-child,
.wpdevelop .control-group .btn-toolbar .btn-group > .button:first-child,
.wpdevelop .control-group .btn-toolbar .btn-group > input[type=text]:first-child,
.wpdevelop .control-group .btn-toolbar .btn-group > select:first-child {
border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
-webkit-border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
-webkit-border-top-left-radius: 4px;
}
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text']:last-child,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn:last-child .button,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon:last-child,
.wpdevelop .control-group .btn-toolbar .btn-group > .button:last-child,
.wpdevelop .control-group .btn-toolbar .btn-group > input[type=text]:last-child,
.wpdevelop .control-group .btn-toolbar .btn-group > select:last-child {
border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
-webkit-border-top-right-radius: 4px;
margin-left: -1px;
}
.wpdevelop .control-group .btn-group .dropdown-toggle label{
margin-bottom: 3px;
}
.wpdevelop .control-group .btn-group .dropdown-toggle span.opsd_selected_in_dropdown{
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
}
/* .form-group */
.wpdevelop .form-group .input-group > .button,
.wpdevelop .form-group .input-group .input-group-btn .button {
display: inline-block;
font-size: 14px;
font-weight: 400;
height:34px;
line-height: 1.42857;
margin-bottom: 0;
padding: 6px 12px;
text-align: center;
vertical-align: middle;
white-space: nowrap;
border-radius: 0;
-moz-border-radius: 0;
-webkit-border-radius: 0;
}
.wpdevelop .form-group .input-group .input-group-btn .btn-toolbar .btn-group .button {
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
margin:0;
}
.wpdevelop .form-group .input-group > .button:first-child,
.wpdevelop .form-group .input-group > input[type=text]:first-child,
.wpdevelop .form-group .input-group > select:first-child,
.wpdevelop .form-group .input-group .input-group-btn:first-child .button,
.wpdevelop .form-group .input-group .input-group-btn .btn-toolbar .btn-group .button:first-child{
border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
-webkit-border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
-webkit-border-top-left-radius: 4px;
margin-left: 0;
}
.wpdevelop .form-group .input-group > .button:last-child,
.wpdevelop .form-group .input-group > input[type=text]:last-child,
.wpdevelop .form-group .input-group > select:last-child,
.wpdevelop .form-group .input-group > .dropdown-toggle,
.wpdevelop .form-group .input-group > .input-group-btn:last-child .button,
.wpdevelop .form-group .input-group .input-group-btn .btn-toolbar > .btn-group > .button:last-child {
border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
-webkit-border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
-webkit-border-top-right-radius: 4px;
margin-left: -1px;
}
.wpdevelop .form-group .input-group ul.dropdown-menu {
margin-top:0;
border-top-right-radius: 0;
-moz-border-radius-topright: 0;
-webkit-border-top-right-radius: 0;
border-top-left-radius: 0;
-moz-border-radius-topleft: 0;
-webkit-border-top-left-radius: 0;
}
/* Fix: for showing correct width in Chrome. Its trick, so need to test more... 2016-08-31 */
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn {
width:auto;
}
/* .btn-group-vertical */
.wpdevelop .btn-group-vertical > .button,
.wpdevelop .btn-group-vertical > .btn-group,
.wpdevelop .btn-group-vertical > .btn-group > .button {
display: block;
float: none;
width: 100%;
max-width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin-bottom: 0;
}
.wpdevelop .btn-group-vertical > .btn-group > .button {
float: none;
}
.wpdevelop .btn-group-vertical > .button + .button,
.wpdevelop .btn-group-vertical > .button + .btn-group,
.wpdevelop .btn-group-vertical > .btn-group + .button,
.wpdevelop .btn-group-vertical > .btn-group + .btn-group {
margin-top: -1px;
margin-left: 0;
}
.wpdevelop .btn-group-vertical > .button:not(:first-child):not(:last-child) {
border-radius: 0;
}
.wpdevelop .btn-group-vertical > .button:first-child:not(:last-child) {
border-top-right-radius: 4px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.wpdevelop .btn-group-vertical > .button:last-child:not(:first-child) {
border-bottom-left-radius: 4px;
border-top-right-radius: 0;
border-top-left-radius: 0;
}
.wpdevelop .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .button {
border-radius: 0;
}
.wpdevelop .btn-group-vertical > .btn-group:first-child:not(:last-child) > .button:last-child,
.wpdevelop .btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle {
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.wpdevelop .btn-group-vertical > .btn-group:last-child:not(:first-child) > .button:first-child {
border-top-right-radius: 0;
border-top-left-radius: 0;
}
/*******************************************************************************/
@media (max-width: 782px) {
.wpdevelop .opsd-sm-100 {
width:100% !important;
}
/* .wpdevelop .control-group .btn-toolbar .input-group {
margin-bottom: 10px;
}*/
.wpdevelop .in-button-text {
display:none;
}
.wpdevelop .control-group .btn-group > .button,
.wpdevelop .control-group .btn-toolbar .btn-group > .button,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button {
height: 34px;
line-height: 1.5em;
}
.wpdevelop .control-group .btn-toolbar .input-group > input[type='text']{
height: 40px;
padding: 0 12px;
line-height: 29px;
font-size: 1.2em;
}
#wpbody .wpdevelop .control-group .btn-toolbar .input-group > select {
height: 34px;
line-height: 28px;
font-size: 1.2em;
}
.wpdevelop .control-group-text {
height: 34px;
line-height: 34px;
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon,
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn {
height: 40px;
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-btn .button {
margin:0 0 0 -1px;
height: 40px;
line-height: 39px;
padding: 0 15px;
}
.wpdevelop .control-group .btn-toolbar .input-group > .input-group-addon {
padding-top:0;
padding-bottom:0;
}
}
@media (max-width: 400px) {
.wpdevelop .opsd-sm-100 {
width:100% !important;
}
}

View File

@@ -0,0 +1,61 @@
/**
* @version 1.0
* @desciption Dismiss Button and System Notices
* @usage Admin panel
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2017-04-23
*/
/* System Notice */
.opsd_page .opsd_system_notice {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
min-height:1em;
height:auto;
padding: 1em;
margin: 5px 0 15px !important;
position: relative;
display: block;
width:100%
}
.opsd_page .opsd_internal_notice {
box-sizing: border-box;
min-height: 1em;
height: auto;
position: relative;
display: block;
width: 100%;
background: #fff;
border-left-style: solid;
border-left-width: 4px;
-moz-box-shadow: 0 0 2px 0 rgba(0,0,0,.2);
-webkit-box-shadow: 0 0 2px 0 rgba(0,0,0,.2);
box-shadow: 0 0 2px 0 rgba(0,0,0,.2);
margin: 5px 15px 2px;
}
.opsd_page .opsd_system_notice a,
.opsd_page .opsd_system_notice a:hover,
.opsd_page .opsd_system_notice a:focus,
.opsd_page .opsd_internal_notice a,
.opsd_page .opsd_internal_notice a:hover,
.opsd_page .opsd_internal_notice a:focus {
text-decoration: none;
}
/* Dismiss X button */
.opsd_page .opsd_dismiss,
.opsd_page a.opsd_dismiss:hover,
.opsd_page a.opsd_dismiss:focus{
font-size: 18px;
float: right;
text-decoration: none;
padding: 5px 10px 10px;
margin: -7px;
outline: none;
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,74 @@
/**
* @version 1.0
* @package: Admin Panel
* @category: Admin UI
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-04-11
*/
/* Admin Content Pages */
.opsd_page .opsd_admin_page .opsd_header_margin {
height:10px;
}
/* Collapse & expand elements in settings meta boxes */
.opsd_page .meta-box .postbox .handlediv {
background: url("../../../../../../wp-admin/images/arrows.png") no-repeat scroll 5px -27px transparent;
}
.opsd_page .meta-box .postbox.closed .handlediv {
background-position:5px 10px;
}
.opsd_page .meta-box .postbox .handlediv:hover {
cursor: pointer !important;
}
.opsd_page .meta-box .postbox .hndle:hover {
cursor: default !important;
}
/* Settings Menuboxes */
.opsd_settings_row.opsd_settings_row_left {
width:64%;
float:left;
margin-right:1%;
}
.opsd_settings_row.opsd_settings_row_right {
width:35%;
float:left;
}
/* Set switched Meta Boxes size*/
.opsd_settings_row.opsd_settings_row_left_small {
width:35%;
}
.opsd_settings_row.opsd_settings_row_right_big {
width:64%;
}
/* FixIn: 7.0.1.54 */
.opsd_page input::-moz-placeholder,
.opsd_page textarea::-moz-placeholder{
color: #ccc;
opacity: 1;
}
.opsd_page input:-ms-input-placeholder,
.opsd_page textarea:-ms-input-placeholder{
color: #ccc;
}
.opsd_page input::-webkit-input-placeholder,
.opsd_page textarea::-webkit-input-placeholder{
color: #ccc;
}
/* iPad mini and all iPhones and other Mobile Devices */
@media (max-width: 782px) {
/* Settings Top TABS */
.opsd_page .opsd_admin_page .metabox-holder .opsd_settings_row {
width:100%;
float:none;
}
.opsd_text_hide_mobile {
display:none;
}
}

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,81 @@
<?php /**
* @version 1.0
* @package: Emails
* @category: Templates
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-06-16
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* get email template
*
* @param array $fields_values
*/
function opsd_email_template_plain_html( $fields_values ) {
ob_start();
// $base_color = 'background-color:' . ( empty( $fields_values['base_color'] ) ? '#557da1' : $fields_values['base_color'] ) . ';';
// $background_color = 'background-color:' . ( empty( $fields_values['background_color'] ) ? '#FDFDFD' : $fields_values['background_color'] ) . ';';
// $body_color = 'background-color:' . ( empty( $fields_values['body_color'] ) ? '#F5F5F5' : $fields_values['body_color'] ) . ';';
// $text_color = 'color:' . ( empty( $fields_values['text_color'] ) ? '#333333' : $fields_values['text_color'] ) . ';';
$base_color = '';
$background_color = '';
$body_color = '';
$text_color = '';
////////////////////////////////////////////////////////////////////////////////
// HTML Email Template
////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <!-- dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
</head>
<body style="Margin:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;min-width:100%;<?php echo $body_color; ?>" <?php echo is_rtl() ? 'rightmargin="0"' : 'leftmargin="0"'; ?> >
<div class="wrapper" style="table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;Margin:0;padding-top:10px;padding-bottom:10px;padding-right:10px;padding-left:10px;<?php echo $body_color; ?>" <?php echo is_rtl() ? 'dir="rtl"' : 'dir="ltr"'?> >
<?php
if ( ! empty( $fields_values['header_content'] ) ) {
?><p style="Margin:0;Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;line-height:150%;font-size:14px;" ><?php
echo ( wp_kses_post( wptexturize( $fields_values['header_content'] ) ) );
?></p><?php
}
?><p style="Margin:0;font-size:14px;Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;line-height:150%;<?php echo $text_color; ?>" ><?php
$h2_headers = array('<p class="h2" style="Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;display:block;font-size:18px;font-weight:bold;line-height:130%;Margin:16px 0 8px;text-align:left;color:#557da1;" >', '</p>');
$fields_values['content'] = str_replace( array( '<h2>', '</h2>' ), $h2_headers, $fields_values['content'] );
echo ( wp_kses_post( wptexturize( $fields_values['content'] ) ) );
?></p><?php
if ( ! empty( $fields_values['footer_content'] ) ) {
?><p style="Margin:0;Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;line-height:150%;font-size:11px;" ><?php
echo ( wp_kses_post( wptexturize( $fields_values['footer_content'] ) ) );
?></p><?php
}
?>
</div>
</body>
<?php
return ob_get_clean(); // Return this email content
}

View File

@@ -0,0 +1,37 @@
<?php /**
* @version 1.0
* @package: Emails
* @category: Templates
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-06-16
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* get email template
*
* @param array $fields_values
*/
function opsd_email_template_plain_text( $fields_values ) {
ob_start();
if ( ! empty($fields_values['header_content'] ) ) {
echo wp_kses_post( wptexturize( $fields_values['header_content'] ) ) . "\n\n"; //Header
}
echo ( wp_kses_post( wptexturize( $fields_values['content'] ) ) ); //Content
if ( ! empty( $fields_values['footer_content'] ) ) {
echo "\n\n" . wp_kses_post( wptexturize( $fields_values['footer_content'] ) ); //Footer
}
return ob_get_clean(); // Return this email content
}

View File

@@ -0,0 +1,654 @@
<?php /**
* @version 1.0
* @package: Emails
* @category: Templates
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-06-16
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* get email template
*
* @param array $fields_values
*/
function opsd_email_template_standard_html( $fields_values ) {
ob_start();
$base_color = 'background-color:' . ( empty( $fields_values['base_color'] ) ? '#557da1' : $fields_values['base_color'] ) . ';';
$background_color = 'background-color:' . ( empty( $fields_values['background_color'] ) ? '#FDFDFD' : $fields_values['background_color'] ) . ';';
$body_color = 'background-color:' . ( empty( $fields_values['body_color'] ) ? '#F5F5F5' : $fields_values['body_color'] ) . ';';
$text_color = 'color:' . ( empty( $fields_values['text_color'] ) ? '#333333' : $fields_values['text_color'] ) . ';';
////////////////////////////////////////////////////////////////////////////////
// HTML Email Template
////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <!-- dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style type="text/css">
body {
Margin: 0;
padding: 0;
min-width: 100%;
<?php echo $background_color; ?>
}
table {
border-spacing: 0;
font-family: sans-serif;
<?php echo $text_color; ?>
}
td {
padding: 0;
}
img {
border: 0;
}
.wrapper {
width: 100%;
table-layout: fixed;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
Margin: 0;
padding: 70px 0 70px 0;
<?php echo $background_color; ?>
}
.webkit {
max-width: 600px;
}
@-ms-viewport {
width: device-width;
}
.outer {
Margin: 0 auto;
width: 96%;
max-width: 600px;
box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
border: 1px solid #dcdcdc;
border-radius: 3px !important;
<?php echo $body_color; ?>
}
.full-width-image img {
width: 100%;
height: auto;
}
.header {
border-radius: 3px 3px 0 0 !important;
color: #ffffff; border-bottom: 0;
font-weight: bold;
line-height: 100%;
vertical-align: middle;
font-family: Helvetica, Roboto, Arial, sans-serif;
<?php echo $base_color; ?>
}
.footer .inner {
text-align: center;
}
.footer .inner p {
font-size: 11px;
}
.inner {
padding: 48px;
}
.header .inner {
padding: 10px;
}
p {
Margin: 0;
}
p.footer {
font-size: 11px;
}
a {
color: #ee6a56;
text-decoration: underline;
}
.h1 {
font-size: 21px;
font-weight: bold;
Margin-bottom: 18px;
}
.header .inner .h1 {
color: #ffffff;
display: block;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 30px;
font-weight: 300;
line-height: 150%;
Margin: 0;
padding: 26px 48px;
text-align: left;
text-shadow: 0 1px 0 #7797b4;
-webkit-font-smoothing: antialiased;
}
.h2 {
font-size: 18px;
font-weight: bold;
Margin-bottom: 12px;
}
.one-column .contents {
text-align: left;
}
.one-column p {
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
.one-column p.h2,
.two-column .column .contents p.h2 {
display: block;
font-size: 18px;
font-weight: bold;
line-height: 130%;
Margin: 16px 0 8px;
text-align: left;
color: #557da1;
}
.two-column {
text-align: center;
font-size: 0;
}
.two-column .column {
width: 100%;
max-width: 280px;
display: inline-block;
vertical-align: top;
}
.two-column .column .contents p{
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
.two-column .inner,
.footer .inner {
padding: 10px 48px;
}
.contents {
width: 100%;
}
.header .inner {
width: 100%;
}
.footer .inner {
width: 100%;
border-top:1px solid #dddddd;
}
.two-column .contents {
font-size: 14px;
text-align: left;
}
.two-column img {
width: 100%;
height: auto;
}
.two-column .text {
padding-top: 10px;
}
.two-column p {
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
@media screen and (max-width: 400px) {
.two-column .column {
max-width: 100% !important;
}
}
@media screen and (min-width: 401px) and (max-width: 620px) {
.two-column .column {
max-width: 50% !important;
}
}
</style>
<!--[if (gte mso 9)|(IE)]>
<style type="text/css">
table {border-collapse: collapse !important;}
</style>
<![endif]-->
</head>
<body style="Margin:0;padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;min-width:100%;<?php echo $background_color; ?>" <?php echo is_rtl() ? 'rightmargin="0"' : 'leftmargin="0"'; ?> >
<center class="wrapper" style="width:100%;table-layout:fixed;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;Margin:0;padding-top:70px;padding-bottom:70px;padding-right:0;padding-left:0;<?php echo $background_color; ?>" <?php echo is_rtl() ? 'dir="rtl"' : 'dir="ltr"'?> >
<div class="webkit" style="max-width:600px;" >
<!--[if (gte mso 9)|(IE)]>
<table width="600" align="center" style="border-spacing:0;font-family:sans-serif;<?php echo $text_color; ?>" >
<tr>
<td style="padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;" >
<![endif]-->
<table class="outer" align="center" style="border-spacing:0;font-family:sans-serif;<?php echo $text_color; ?><?php echo $body_color; ?>Margin:0 auto;width:96%;max-width:600px;box-shadow:0 1px 4px rgba(0,0,0,0.1) !important;border-width:1px;border-style:solid;border-color:#dcdcdc;border-radius:3px !important;" >
<?php if ( ! empty( $fields_values['header_img600_src'] ) ) { ?>
<!-- Header IMG: 1 column template row -->
<tr> <!-- This image must be 600px width (NOT wider). If less, then we need to set in CSS width in px of this image -->
<td class="full-width-image" style="padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;" >
<img src="images/header.jpg" alt="" style="border-width:0;width:100%;height:auto;" /> <!-- src="<?php $fields_values['header_img600_src']; ?>" -->
</td>
</tr>
<?php } ?>
<!-- Header: 1 column template row -->
<tr>
<td class="one-column" style="padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;" >
<table width="100%" class="header" style="<?php echo $base_color; ?>border-spacing:0;border-radius:3px 3px 0 0 !important;color:#ffffff;border-bottom-width:0;font-weight:bold;line-height:100%;vertical-align:middle;font-family:Helvetica, Roboto, Arial, sans-serif;" >
<tr>
<td class="inner" style="padding-top:10px;padding-bottom:10px;padding-right:10px;padding-left:10px;width:100%;" >
<p class="h1" style="Margin-bottom:10px;color:#ffffff;display:block;font-family:Helvetica, Roboto, Arial, sans-serif;font-size:30px;font-weight:300;line-height:150%;Margin:0;padding-top:26px;padding-bottom:26px;padding-right:48px;padding-left:48px;text-align:left;text-shadow:0 1px 0 #7797b4;-webkit-font-smoothing:antialiased;" ><?php echo ( wp_kses_post( wptexturize( $fields_values['header_content'] ) ) ); ?></p>
</td>
</tr>
</table>
</td>
</tr>
<!-- Content: 1 column template row -->
<tr>
<td class="one-column" style="padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;" >
<table width="100%" style="border-spacing:0;font-family:sans-serif;<?php echo $text_color; ?>" >
<tr>
<td class="inner contents" style="padding-top:48px;padding-bottom:48px;padding-right:48px;padding-left:48px;width:100%;text-align:left;" >
<p style="Margin:0;font-size:14px;Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;line-height:150%;color:#737373;" ><?php
$h2_headers = array('<p class="h2" style="Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;display:block;font-size:18px;font-weight:bold;line-height:130%;Margin:16px 0 8px;text-align:left;color:#557da1;" >', '</p>');
$fields_values['content'] = str_replace( array( '<h2>', '</h2>' ), $h2_headers, $fields_values['content'] );
echo ( wp_kses_post( wptexturize( $fields_values['content'] ) ) );
?></p>
</td>
</tr>
</table>
</td>
</tr>
<!-- Footer: 1 column template row -->
<tr>
<td class="one-column" style="padding-top:0;padding-bottom:0;padding-right:0;padding-left:0;" >
<table width="100%" class="footer" style="border-spacing:0;font-family:sans-serif;<?php echo $text_color; ?>" >
<tr>
<td class="inner" style="text-align:center;padding-top:10px;padding-bottom:10px;padding-right:48px;padding-left:48px;width:100%;border-top-width:1px;border-top-style:solid;border-top-color:#dddddd;" >
<p style="Margin:0;Margin-bottom:10px;font-family:Helvetica, Roboto, Arial, sans-serif;line-height:150%;color:#737373;font-size:11px;" >
<?php /* <a style="color:#ee6a56;text-decoration:underline;" >Forward to a Friend</a> &nbsp; &nbsp; <a style="color:#ee6a56;text-decoration:underline;" >Unsubscribe</a> &nbsp; &nbsp; <a style="color:#ee6a56;text-decoration:underline;" >Preferences</a><br /> */
echo ( wp_kses_post( wptexturize( $fields_values['footer_content'] ) ) ); ?>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</div>
</center>
</body>
<?php
return ob_get_clean(); // Return this email content
}
return;
// Exist from this file, at the bottom - original static HTML template for email
// <editor-fold defaultstate="collapsed" desc=" Source Code of template for parsing at http://inliner.cm/ " >
////////////////////////////////////////////////////////////////////////////////
// Source Code of template for parsing at http://inliner.cm/
////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <!-- dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<style type="text/css">
body {
Margin: 0;
padding: 0;
min-width: 100%;
background-color: #ffffff;
}
table {
border-spacing: 0;
font-family: sans-serif;
color: #333333;
}
td {
padding: 0;
}
img {
border: 0;
}
.wrapper {
width: 100%;
table-layout: fixed;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
Margin: 0;
padding: 70px 0 70px 0;
background-color: #f5f5f5;
}
.webkit {
max-width: 600px;
}
@-ms-viewport {
width: device-width;
}
/* width 100% */
.outer {
Margin: 0 auto;
width: 96%;
max-width: 600px;
box-shadow: 0 1px 4px rgba(0,0,0,0.1) !important;
border: 1px solid #dcdcdc;
border-radius: 3px !important;
background-color: #fdfdfd;
}
.full-width-image img {
width: 100%;
height: auto;
}
.header {
border-radius: 3px 3px 0 0 !important;
color: #ffffff; border-bottom: 0;
font-weight: bold;
line-height: 100%;
vertical-align: middle;
font-family: Helvetica, Roboto, Arial, sans-serif;
background-color: #557da1;
}
.footer .inner {
text-align: center;
}
.footer .inner p {
font-size: 11px;
}
.inner {
padding: 48px;
}
.header .inner {
padding: 10px;
}
p {
Margin: 0;
}
p.footer {
font-size: 11px;
}
a {
color: #ee6a56;
text-decoration: underline;
}
.h1 {
font-size: 21px;
font-weight: bold;
Margin-bottom: 18px;
}
.header .inner .h1 {
color: #ffffff;
display: block;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 30px;
font-weight: 300;
line-height: 150%;
Margin: 0;
padding: 26px 48px;
text-align: left;
text-shadow: 0 1px 0 #7797b4;
-webkit-font-smoothing: antialiased;
}
.h2 {
font-size: 18px;
font-weight: bold;
Margin-bottom: 12px;
}
.one-column .contents {
text-align: left;
}
.one-column p {
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
.one-column p.h2,
.two-column .column .contents p.h2 {
display: block;
font-size: 18px;
font-weight: bold;
line-height: 130%;
Margin: 16px 0 8px;
text-align: left;
color: #557da1;
}
.two-column {
text-align: center;
font-size: 0;
}
/* Previously 300px. - TODO: need to test if we really need to have here 280 or 300px in the different email applications. Also its possible that we need to have header images, not 280px but only 260px.... */
.two-column .column {
width: 100%;
max-width: 280px;
display: inline-block;
vertical-align: top;
}
.two-column .column .contents p{
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
.two-column .inner,
.footer .inner {
padding: 10px 48px;
}
.contents {
width: 100%;
}
.header .inner {
width: 100%;
}
.footer .inner {
width: 100%;
border-top:1px solid #dddddd;
}
.two-column .contents {
font-size: 14px;
text-align: left;
}
.two-column img {
width: 100%;
height: auto;
}
.two-column .text {
padding-top: 10px;
}
.two-column p {
font-size: 14px;
Margin-bottom: 10px;
font-family: Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
color: #737373;
}
/*Media Queries*/
@media screen and (max-width: 400px) {
.two-column .column {
max-width: 100% !important;
}
}
@media screen and (min-width: 401px) and (max-width: 620px) {
.two-column .column {
max-width: 50% !important;
}
}
</style>
<!--[if (gte mso 9)|(IE)]>
<style type="text/css">
table {border-collapse: collapse;}
</style>
<![endif]-->
</head>
<body> <!-- <?php echo is_rtl() ? 'rightmargin="0"' : 'leftmargin="0"'; ?> -->
<center class="wrapper" > <!-- <?php echo is_rtl() ? 'dir="rtl"' : 'dir="ltr"'?> -->
<div class="webkit">
<!--[if (gte mso 9)|(IE)]>
<table width="600" align="center">
<tr>
<td>
<![endif]-->
<table class="outer" align="center">
<!-- <?php if ( ! empty( $fields_values['header_img600_src'] ) ) { ?> -->
<!-- Header IMG: 1 column template row -->
<tr> <!-- This image must be 600px width (NOT wider). If less, then we need to set in CSS width in px of this image -->
<td class="full-width-image">
<img src="images/header.jpg" alt="" /> <!-- src="<?php $fields_values['header_img600_src']; ?>" -->
</td>
</tr>
<!-- <?php } ?> -->
<!-- Header: 1 column template row -->
<tr>
<td class="one-column">
<table width="100%" class="header">
<tr>
<td class="inner">
<p class="h1">HTML Email Header</p> <!-- <?php echo ( wp_kses_post( wptexturize( $fields_values['header_content'] ) ) ); ?> -->
</td>
</tr>
</table>
</td>
</tr>
<!-- Content: 1 column template row -->
<tr>
<td class="one-column">
<table width="100%">
<tr>
<td class="inner contents"> <!-- <?php echo ( wp_kses_post( wptexturize( $fields_values['content'] ) ) ); ?> -->
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet diam a facilisis eleifend. Cras ac justo felis. Mauris faucibus, orci eu blandit fermentum, lorem nibh sollicitudin mi, sit amet interdum metus urna ut lacus.</p>
<p class="h2">Lorem ipsum dolor</p>
<p>Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo.</p>
</td>
</tr>
</table>
</td>
</tr>
<!-- <?php if ( ( ! empty( $fields_values['content_column_1'] ) ) && ( ! empty( $fields_values['content_column_2'] ) ) ) { ?> -->
<!-- Content: 2 columns template row -->
<tr>
<td class="two-column">
<!--[if (gte mso 9)|(IE)]>
<table width="100%">
<tr>
<td width="50%" valign="top">
<![endif]-->
<div class="column">
<!-- Column 1 -->
<table width="100%">
<tr>
<td class="inner">
<table class="contents">
<!-- <?php if ( ! empty( $fields_values['header_column_1_img260_src'] ) ) { ?> -->
<tr>
<td>
<!-- width of image must be 260px -->
<img src="images/two-column-01.jpg" alt="" /> <!-- src="<?php $fields_values['header_column_1_img260_src']; ?>" -->
</td>
</tr>
<!-- <?php } ?> -->
<tr>
<td class="text"> <!-- <?php echo ( wp_kses_post( wptexturize( $fields_values['content_column_1'] ) ) ); ?> -->
<p>Column 1 Content .... Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet diam a facilisis eleifend. Cras ac justo felis. Mauris faucibus, orci eu blandit fermentum, lorem nibh sollicitudin mi, sit amet interdum metus urna ut lacus. </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--[if (gte mso 9)|(IE)]>
</td><td width="50%" valign="top">
<![endif]-->
<div class="column">
<!-- Column 2 -->
<table width="100%">
<tr>
<td class="inner">
<table class="contents">
<!-- <?php if ( ! empty( $fields_values['header_column_2_img260_src'] ) ) { ?> -->
<tr>
<td>
<!-- width of image must be 260px -->
<img src="images/two-column-02.jpg" alt="" /> <!-- src="<?php $fields_values['header_column_2_img260_src']; ?>" -->
</td>
</tr>
<!-- <?php } ?> -->
<tr>
<td class="text"> <!-- <?php echo ( wp_kses_post( wptexturize( $fields_values['content_column_2'] ) ) ); ?> -->
<p>Column 2 Content .... Fusce eu euismod leo, a accumsan tellus. Quisque vitae dolor eu justo cursus egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet sapien odio. Sed pellentesque arcu mi, quis malesuada lectus lacinia et. Cras a tempor leo. </p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</td>
</tr>
<!-- <?php } ?> -->
<!-- Footer: 1 column template row -->
<tr>
<td class="one-column">
<table width="100%" class="footer">
<tr>
<td class="inner"> <!-- <?php echo ( wp_kses_post( wptexturize( $fields_values['footer_content'] ) ) ); ?> -->
<p>
<a>Forward to a Friend</a> &nbsp; &nbsp; <a>Unsubscribe</a> &nbsp; &nbsp; <a>Preferences</a><br />
You are receiving this email because you are either purchased product at OPSD or you entered your email at OPSD
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</div>
</center>
</body>
<?php
// </editor-fold>

View File

@@ -0,0 +1,41 @@
<?php /**
* @version 1.0
* @package: Emails
* @category: Templates
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-06-16
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* get email template
*
* @param array $fields_values
*/
function opsd_email_template_standard_text( $fields_values ) {
ob_start();
if ( ! empty($fields_values['header_content'] ) ) {
echo "= " . wp_kses_post( wptexturize( $fields_values['header_content'] ) ) . " =\n\n";
echo "----------------------------------------------------------------------\n\n";
}
echo ( wp_kses_post( wptexturize( $fields_values['content'] ) ) );
if ( ! empty( $fields_values['footer_content'] ) ) {
echo "\n---------------------------------------------------------------------\n\n";
echo ( wp_kses_post( wptexturize( $fields_values['footer_content'] ) ) );
}
return ob_get_clean(); // Return this email content
}

View File

@@ -0,0 +1,7 @@
<?php
// Silence is golden.
// Replace OPSD to ...
// _opsd_ to _bk_ (...) in get_opsd_option ....
// - opsd to ...
// , 'secure-downloads') ==> ...

View File

@@ -0,0 +1,622 @@
/**
* @version 1.0
* @package Support Functions
* @subpackage BackEnd Main Script Lib
* @category Scripts
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-04-09
*/
/** Scroll to specific HTML element
*
* @param {type} object_name
* @returns {undefined}
*/
function opsd_scroll_to( object_name ) {
if ( jQuery( object_name ).length > 0 ) {
var targetOffset = jQuery( object_name ).offset().top;
// targetOffset = targetOffset - 50;
if (targetOffset<0) targetOffset = 0;
if ( jQuery('#wpadminbar').length > 0 ) targetOffset = targetOffset - 50;
else targetOffset = targetOffset - 20;
jQuery('html,body').animate({scrollTop: targetOffset}, 500);
}
}
function opsd_animate_border( element, time, colors, x ) {
if (x >= colors.length) {
x = 0;
} else {
x++;
var color;
if ( colors[x] === '' ) {
color = ''
} else {
color = '#'+colors[x]
}
element.css('border-color', color)
setTimeout(function() {
opsd_animate_border( element, time, colors, x );
}, time)
}
}
function opsd_field_highlight( object_name ) {
if ( jQuery( object_name ).length > 0 ) {
opsd_scroll_to( object_name );
opsd_animate_border(
jQuery( object_name ) // Element
, 200 // Time in ms
, ['f87000', '', 'f87000', '', 'f87000', '', 'f87000', '', 'f87000', '', 'f87000', ''] // Colors Array
, 0
);
}
}
/** Show Yes/No dialog
*
* @param {type} message_question
* @returns {Boolean}
*/
function opsd_are_you_sure( message_question ){
var answer = confirm( message_question );
if ( answer) { return true; }
else { return false;}
}
function opsd_admin_show_message_processing( message_type ){
var message = '' ;
if ( message_type == 'saving' )
message += opsd_message_saving;
else if ( message_type == 'updating' )
message += opsd_message_updating;
else if ( message_type == 'deleting' )
message += opsd_message_deleting;
else
message += opsd_message_processing;
if ( message == 'undefined' )
message = 'Processing'
message = ' <span class="wpdevelop"><span class="glyphicon glyphicon-refresh opsd_spin opsd_ajax_icon" aria-hidden="true"></span></span> ' + message + '...';
opsd_admin_show_message( message, 'info', 10000 );
}
/** Show Alert Messages
*
* @param {type} message
* @param {type} m_type
* @param {type} m_delay
* @returns {undefined}
*/
function opsd_admin_show_message( message, m_type, m_delay ){
var alert_class = 'notice '; //'alert ';
if (m_type == 'error') alert_class += 'notice-error '; //'alert-danger ';
if (m_type == 'warning') alert_class += 'notice-warning ';
if (m_type == 'info') alert_class += 'notice-info '; //'alert-info ';
if (m_type == 'success') alert_class += 'alert-success updated ';
jQuery('#ajax_working').html( '<div id="opsd_alert_message" class="opsd_alert_message">' +
'<div class="opsd_inner_message '+alert_class+'"> ' +
'<a class="close" href="javascript:void(0)" onclick="javascript:jQuery(this).parent().hide();">&times;</a> ' +
message +
'</div>' +
'</div>'
);
jQuery('#opsd_alert_message').animate( {opacity: 1}, m_delay ).fadeOut(500);
}
function opsd_close_dropdown_selectbox( selector_id ) {
jQuery('#' + selector_id + '_container li input[type=checkbox],#' + selector_id + '_container li input[type=radio]').prop('checked', false);
jQuery('#' + selector_id + '_container').hide();
}
// Show Container depend from the selected option in dropdown list
function opsd_show_selected_in_dropdown( selector_id, title, value ){
jQuery('#' + selector_id + '_selector .opsd_selected_in_dropdown').html( title );
jQuery('#' + selector_id ).val( value );
}
// Show Container depend from the selected Radio Option and Selectbox value in dropdown list
// Exmaple: opsd_show_selected_in_dropdown__radio_select_option( 'wh_ ... _date', 'wh_ ... _date2', 'wh_ ... _datedays_interval_Radios' );
function opsd_show_selected_in_dropdown__radio_select_option( selector_id, selector_id2, radio_name ){
// Get selected value in radio buttons
var rad_val = jQuery('input:radio[name="' + radio_name + '"]:checked').val();
if ( rad_val != 'undefined' ) {
var select_box = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select');
// Selectbox exist
if ( select_box.length > 0 ) {
// Get label near selected radiobutton and selected Tilte in selectbox
var title = jQuery('input:radio[name="' + radio_name + '"]:checked').parent().find('label').html() + ' ' +
jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select option:selected').text();
// Get Value of selected option in selectbox
var value = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.input-group').find('select option:selected').val();
// Set Title in dropdown list
jQuery('#' + selector_id + '_selector .opsd_selected_in_dropdown').html( title );
// Set value of radio button
jQuery('#' + selector_id ).val( rad_val );
// Set value of selectbox
jQuery('#' + selector_id2 ).val( value );
} else {
// 2 Text Fields
var text_box = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('input[type="text"]');
if ( text_box.length > 0 ) {
var text_divs = jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('.dropdown-menu-text-element');
// Check if we have 2 DIV elements with text fields
if ( text_box.length > 0 ) {
var id_list = [ selector_id, selector_id2 ];
var title = '';
//Loop our text DIV elements
jQuery('input:radio[name="' + radio_name + '"]:checked').parents('.text-group').find('.dropdown-menu-text-element').each(function( i ) {
if ( title != '' )
title += ' - ';
title += jQuery(this).find('input[type="text"]').val();
jQuery('#' + id_list[ i ] ).val( jQuery(this).find('input[type="text"]').val() );
});
// Set Title in dropdown list
jQuery('#' + selector_id + '_selector .opsd_selected_in_dropdown').html( title );
}
}
}
}
// Hide dropdown list
jQuery('#' + selector_id + '_container').hide();
}
//Set status of all checkbos in one time
function opsd_set_checkbox_in_table( el_stutus, el_class ){
jQuery('.'+el_class).attr('checked', el_stutus);
if ( el_stutus ) {
jQuery('.'+el_class).parent().parent().parent().parent().addClass('row_selected_color');
// jQuery('.'+el_class).parent().parent().addClass('warning');
} else {
jQuery('.'+el_class).parent().parent().parent().parent().removeClass('row_selected_color');
// jQuery('.'+el_class).parent().parent().removeClass('warning');
}
}
/** Ajax Request
*
* @param {type} us_id
* @param {type} window_id
* @returns {undefined}
*/
//<![CDATA[
function opsd_verify_window_opening( us_id, window_id ){
var is_closed = 0;
if (jQuery('#' + window_id ).hasClass('closed') == true){
jQuery('#' + window_id ).removeClass('closed');
} else {
jQuery('#' + window_id ).addClass('closed');
is_closed = 1;
}
jQuery.ajax({ // Start Ajax Sending
url: opsd_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { alert('Error: 500'); } } ,
// beforeSend: someFunction,
data:{
action: 'USER_SAVE_WINDOW_STATE',
user_id: us_id ,
window: window_id,
is_closed: is_closed,
opsd_nonce: jQuery('#opsd_admin_panel_nonce').val()
}
});
}
//]]>
/** Ajax Request - Saving Custom Data for User
*
* @param {int} us_id
* @param {string} data_name
* @param {string} data_value - serialized data
* @param {int} is_reload - { 0 | 1 } reload or not page
*/
//<![CDATA[
function opsd_save_custom_user_data( us_id, data_name, data_value , is_reload ){
opsd_admin_show_message_processing( 'saving' );
jQuery.ajax({ // Start Ajax Sending
url: opsd_ajaxurl,
type:'POST',
success: function (data, textStatus){if( textStatus == 'success') jQuery('#ajax_respond').html( data );},
error:function (XMLHttpRequest, textStatus, errorThrown){ window.status = 'Ajax sending Error status:'+ textStatus; alert(XMLHttpRequest.status + ' ' + XMLHttpRequest.statusText); if ( XMLHttpRequest.status == 500 ) { alert('Error: 500'); } } ,
// beforeSend: someFunction,
data:{
action: 'USER_SAVE_CUSTOM_DATA',
user_id: us_id,
data_name: data_name,
data_value: decodeURIComponent( data_value ),
is_reload: is_reload,
opsd_nonce: jQuery('#opsd_admin_panel_nonce').val()
}
});
}
//]]>
////////////////////////////////////////////////////////////////////////////////
// Contact Form
////////////////////////////////////////////////////////////////////////////////
function opsd_submit_client_form( submit_form, wpdev_active_locale ){
var count = submit_form.elements.length;
var formdata = '';
var inp_value;
var element;
var el_type;
for (i=0; i<count; i++) {
element = submit_form.elements[i];
if ( (element.type !=='button') && (element.type !=='hidden') ) {
// Get Value of Element
if ( element.type == 'checkbox' ){
if ( element.value == '' ) {
inp_value = element.checked;
} else {
if ( element.checked )
inp_value = element.value;
else
inp_value = '';
}
} else if ( element.type == 'radio' ) {
if ( element.value == '' ) {
inp_value = element.checked;
} else {
if ( element.checked )
inp_value = element.value;
else
inp_value = '';
}
/*
if ( element.checked )
inp_value = element.value;
else
continue;
*/
} else {
inp_value = element.value;
}
// Get value in selectbox of multiple selection
if (element.type =='select-multiple') {
inp_value = jQuery('[name="'+element.name+'"]').val() ;
if ( ( inp_value == null ) || ( inp_value.toString() == '' ) )
inp_value='';
}
/*if ( element.name == ('phone') ) {
// we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no + sign in front the number - See more at: http://www.w3resource.com/javascript/form/phone-no-validation.php#sthash.U9FHwcdW.dpuf
var reg = /^\d{10}$/;
var message_verif_phone = "Please enter correctly phone number";
if ( inp_value != '' )
if(reg.test(inp_value) == false) {opsd_show_error_message( element , message_verif_phone);return;}
}*/
// Validation Check -- Requred fields
if ( element.className.indexOf( 'opsd-validate-required' ) !== -1 ){
if ( ( element.type =='checkbox' ) && ( element.checked === false ) ) {
if ( ! jQuery(':checkbox[name="'+element.name+'"]', submit_form).is(":checked") ) {
opsd_show_error_message( element , opsd_global1.message_verif_requred_for_check_box);
return;
}
}
if ( element.type =='radio' ) {
if ( ! jQuery(':radio[name="'+element.name+'"]', submit_form).is(":checked") ) {
opsd_show_error_message( element , opsd_global1.message_verif_requred_for_radio_box);
return;
}
}
if ( ( element.type !='checkbox' ) && ( element.type !='radio' ) && ( inp_value === '' ) ) {
opsd_show_error_message( element , opsd_global1.message_verif_requred);
return;
}
}
// Validation Check --- Email correct filling field
if ( element.className.indexOf( 'opsd-validate-email' ) !== -1 ){
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,})$/;
if ( ( inp_value != '' ) && ( reg.test(inp_value) == false ) ) {
opsd_show_error_message( element , opsd_global1.message_verif_email );
return;
}
}
/*
// Validation Check --- Same Email Field
if ( ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) && ( element.className.indexOf('same_as_') !== -1 ) ) {
// Get the name of Primary Email field from the "same_as_NAME" class
var primary_email_name = element.className.match(/same_as_([^\s])+/gi);
if (primary_email_name != null) { // We found
primary_email_name = primary_email_name[0].substr(8);
// Recehck if such primary email field exist in the form
if (jQuery('[name="' + primary_email_name + '"]').length > 0) {
// Recheck the values of the both emails, if they do not equla show warning
if ( jQuery('[name="' + primary_email_name + '"]').val() !== inp_value ) {
opsd_show_error_message( element , message_verif_same_emeil );return;
}
}
}
// Skip one loop for the email veryfication field
continue;
} */
/*
// Get Form Data
if ( element.name !== ('captcha_input' ) ) {
if (formdata !=='') formdata += '~'; // next field element
el_type = element.type;
if ( element.className.indexOf('wpdev-validates-as-email') !== -1 ) el_type='email';
if ( element.className.indexOf('wpdev-validates-as-coupon') !== -1 ) el_type='coupon';
inp_value = inp_value + '';
inp_value = inp_value.replace(new RegExp("\\^",'g'), '&#94;'); // replace registered characters
inp_value = inp_value.replace(new RegExp("~",'g'), '&#126;'); // replace registered characters
inp_value = inp_value.replace(/"/g, '&#34;'); // replace double quot
inp_value = inp_value.replace(/'/g, '&#39;'); // replace single quot
formdata += el_type + '^' + element.name + '^' + inp_value ; // element attr
} */
}
} // End Fields Loop
submit_form.submit(); // Submit Form, if previously was no interuptions
}
/**
* Show message under specific element
*
* @param {type} element - jQuery definition of the element
* @param {type} errorMessage - String message
* @param {type} message_type "" | "alert-warning" | "alert-success" | "alert-info" | "alert-danger"
*/
function opsd_show_message_under_element( element , errorMessage , message_type) {
opsd_scroll_to( element );
if ( jQuery( element ).attr('type') == "radio" ) {
jQuery( element ).parent().parent().parent()
.after('<span class="opsd-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
} else if (jQuery( element ).attr('type') == "checkbox") {
jQuery( element ).parent()
.after('<span class="opsd-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
} else {
jQuery( element )
.after('<span class="opsd-near-field-message alert '+ message_type +'">'+ errorMessage +'</span>'); // Show message
}
jQuery(".widget_opsd .opsd-near-field-message")
.css( {'vertical-align': 'sub' } ) ;
jQuery(".opsd-near-field-message")
.animate( {opacity: 1}, 10000 )
.fadeOut( 2000 );
}
// Show Error Message in Form at Front End
function opsd_show_error_message( element , errorMessage) {
// Scroll to the element
opsd_scroll_to( element );
jQuery("[name='"+ element.name +"']")
.fadeOut( 350 ).fadeIn( 300 )
.fadeOut( 350 ).fadeIn( 400 )
.fadeOut( 350 ).fadeIn( 300 )
.fadeOut( 350 ).fadeIn( 400 )
.animate( {opacity: 1}, 4000 )
; // mark red border
if (jQuery("[name='"+ element.name +"']").attr('type') == "radio") {
jQuery("[name='"+ element.name +"']").parent().parent()//.parent()
.after('<span class="opsd-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
} else if (jQuery("[name='"+ element.name +"']").attr('type') == "checkbox") {
jQuery("[name='"+ element.name +"']").parent().parent()
.after('<span class="opsd-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
} else {
jQuery("[name='"+ element.name +"']")
.after('<span class="opsd-near-field-message alert alert-warning">'+ errorMessage +'</span>'); // Show message
}
jQuery(".opsd-near-field-message")
.css( {'padding' : '5px 5px 4px', 'margin' : '2px', 'vertical-align': 'top', 'line-height': '32px' } );
if ( element.type == 'checkbox' )
jQuery(".opsd-near-field-message").css( { 'vertical-align': 'middle'} );
jQuery(".widget_opsd .opsd-near-field-message")
.css( {'vertical-align': 'sub' } ) ;
jQuery(".opsd-near-field-message")
.animate( {opacity: 1}, 10000 )
.fadeOut( 2000 );
element.focus(); // make focus to elemnt
return;
}
/**
* Reload the page with new parameter value.
*
* @param {type} url - full URL of the page, can include or exclude that parameter
* @param {type} param - URL parameter name
* @param {type} value - URL parameter value
* @returns {undefined}
*/
function opsd_reload_page_with_paramater( url, param, value ) {
var hash = {};
var parser = document.createElement('a');
parser.href = url;
var parameters = parser.search.split(/\?|&/);
for(var i=0; i < parameters.length; i++) {
if(!parameters[i])
continue;
var ary = parameters[i].split('=');
hash[ary[0]] = ary[1];
}
hash[param] = value;
var list = [];
Object.keys(hash).forEach(function (key) {
list.push(key + '=' + hash[key]);
});
parser.search = '?' + list.join('&');
//return parser.href;
window.location.href = parser.href;
}
jQuery( window ).on( "load", function (){ //FixIn: 8.7.9.7
// Color Text picker ///////////////////////////////////////////////////////
if ( jQuery('.field-text-color').length > 0 ) {
jQuery('.field-text-color').iris( {
change: function(event, ui){
jQuery(this).css( { backgroundColor: ui.color.toString() } );
jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { color: ui.color.toString() } );
}
, hide: true
, border: true
, palettes: ['#333', '#555', '#777', '#aaa', '#fff']
} ).each( function() {
jQuery(this).css( { backgroundColor: jQuery(this).val() } );
})
.on( 'click', function(){
jQuery('.iris-picker').hide();
jQuery(this).closest('div').find('.iris-picker').show();
});
}
// Color Background picker /////////////////////////////////////////////////
if ( jQuery('.field-background-color').length > 0 ) {
jQuery('.field-background-color').iris( {
change: function(event, ui){
jQuery(this).css( { backgroundColor: ui.color.toString() } );
jQuery(this).closest('.fields-color-group').find('.fieldvalue').css( { backgroundColor: ui.color.toString() } );
}
, hide: true
, border: true
, palettes: [ '#FFEE99', '#459', '#78b', '#ab0', '#df5d5d', '#f0f']
} ).each( function() {
jQuery(this).css( { backgroundColor: jQuery(this).val() } );
})
.on( 'click', function(){
jQuery('.iris-picker').hide();
jQuery(this).closest('div').find('.iris-picker').show();
});
jQuery('.field-text-color, .field-background-color').on( 'click', function(event){
event.stopPropagation();
});
}
////////////////////////////////////////////////////////////////////////////
// General Color picker in settings table //////////////////////////////////
////////////////////////////////////////////////////////////////////////////
if ( jQuery('.opsd_colorpick').length > 0 ) {
jQuery('.opsd_colorpick').iris( {
change: function(event, ui){
jQuery(this).css( { backgroundColor: ui.color.toString() } );
}
, hide: true
, border: true
, palettes: ['#125', '#459', '#78b', '#ab0', '#de3', '#f0f']
} ).each( function() {
jQuery(this).css( { backgroundColor: jQuery(this).val() } );
})
.on( 'click', function(){
jQuery('.iris-picker').hide();
jQuery(this).closest('td').find('.iris-picker').show();
});
jQuery('body').on( 'click', function() {
jQuery('.iris-picker').hide();
});
jQuery('.opsd_colorpick').on( 'click', function(event){
event.stopPropagation();
});
}
});
////////////////////////////////////////////////////////////////////////////
// Support Functions
////////////////////////////////////////////////////////////////////////////
/**
* Reset of WP Editor or TextArea Content
* @param {string} editor_textarea_id - ID of element
* @param {string} editor_textarea_content - Content
*/
function opsd_reset_wp_editor_content( editor_textarea_id, editor_textarea_content ) {
if( typeof tinymce != "undefined" ) {
var editor = tinymce.get( editor_textarea_id );
if( editor && editor instanceof tinymce.Editor ) {
editor.setContent( editor_textarea_content );
editor.save( { no_events: true } );
} else {
jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
}
} else {
jQuery( '#' + editor_textarea_id ).val( editor_textarea_content );
}
}

View File

@@ -0,0 +1,57 @@
/**
* @version 1.0
* @desciption Dismiss Notices - Ajax handler
* @usage Admin panel
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2017-04-23
*/
/** Ajax Request - Dismiss */
jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
jQuery( '.opsd_is_dismissible' ).on( 'click', '.opsd_dismiss', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded
var jq_el = jQuery( this ).closest( '.opsd_is_dismissible' ); // Get dismissible HTML element
var params_obj = {};
params_obj.id = jq_el.attr( 'id' );
params_obj.nonce = jq_el.attr( 'data-nonce' );
params_obj.user_id = jq_el.attr( 'data-user-id' );
jQuery.post( opsd_ajaxurl, {
action: 'OPSD_DISMISS',
user_id: params_obj.user_id ,
nonce: params_obj.nonce,
element_id: params_obj.id,
is_closed: 1
},
function ( response_data, textStatus, jqXHR ) { // success
// console.log( response_data ); console.log( textStatus); console.log( jqXHR ); // Debug
// jQuery( '#ajax_respond' ).html( response_data ); // For ability to show response, add such DIV element to page
}
).fail( function ( jqXHR, textStatus, errorThrown ) { if ( window.console && window.console.log ){ console.log( 'Ajax_Error', jqXHR, textStatus, errorThrown ); } })
// .done( function ( data, textStatus, jqXHR ) { if ( window.console && window.console.log ){ console.log( 'second success', data, textStatus, jqXHR ); } })
// .always( function ( data_jqXHR, textStatus, jqXHR_errorThrown ) { if ( window.console && window.console.log ){ console.log( 'always finished', data_jqXHR, textStatus, jqXHR_errorThrown ); } })
;
});
});
/* Hide */
jQuery( function ( $ ) { // Shortcut to jQuery(document).ready(function(){ ... });
jQuery( '.opsd_is_hideable' ).on( 'click', '.opsd_dismiss', function ( event ) { // This delegated event, can be run, when DOM element added after page loaded
var jq_el = jQuery( this ).closest( '.opsd_is_hideable' ); // Get hideable HTML element
jq_el.hide();
});
});

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,187 @@
<?php /**
* @version 1.0
* @description Dismiss Class
* @category Dismiss panels Class
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-11-13
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Dismiss Class
* @usage:
*
* Inline Setting Notice Dismiss'
*
$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();
....
?></div><?php
*
* System Notice
*
$notice_id = 'opsd_system_notice_free_instead_paid';
if ( ! opsd_section_is_dismissed( $notice_id ) ) {
?><div id="<?php echo $notice_id; ?>"
class="opsd_system_notice opsd_is_dismissible opsd_is_hideable updated notice-warning"
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();
...
?></div><?php
*
*/
final class OPSD_Dismiss {
static private $instance = NULL; // Define only one instance of this class
/** Get only one instance of this class
*
* @return class OPSD_Dismiss
*/
public static function init() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof OPSD_Dismiss ) ) {
self::$instance = new OPSD_Dismiss;
// JS & CSS
add_action( 'opsd_enqueue_js_files', array( self::$instance, 'opsd_js_load_files' ), 50 );
add_action( 'opsd_enqueue_css_files', array( self::$instance, 'opsd_enqueue_css_files' ), 50 );
// Ajax Handlers. Note. "locale_for_ajax" recehcked in opsd-ajax.php
add_action( 'wp_ajax_' . 'OPSD_DISMISS', array( self::$instance, 'opsd_ajax_' . 'OPSD_DISMISS' ) ); // Admin & Client (logged in usres)
//add_action( 'wp_ajax_nopriv_' . 'OPSD_DISMISS', array( self::$instance, 'opsd_ajax_' . 'OPSD_DISMISS' ) ); // Client (not logged in)
}
return self::$instance;
}
/** Ajax Handler
* for request like:
* action: 'OPSD_DISMISS',
user_id: panel_obj.user_id ,
nonce: panel_obj.nonce,
element_id: panel_obj.id,
is_closed: 1
*
*/
public function opsd_ajax_OPSD_DISMISS() {
if ( ! isset( $_POST['element_id'] ) || empty( $_POST['element_id'] ) ) {
exit;
}
$action_name = $_POST['element_id'] . '_opsdnonce';
$nonce_post_key = 'nonce';
// Check Security
$result = check_ajax_referer( $action_name, $nonce_post_key );
// Save status
update_user_option( (int) $_POST[ 'user_id' ], 'opsd_win_' . esc_attr( $_POST[ 'element_id' ] ), (int) $_POST[ 'is_closed' ] );
// send JSON
wp_send_json( array( 'response' => 'success' ) ); // Return JS OBJ: response_data = { response: "success" } in "dismiss.js"
// This function call wp_die( '', '', array( 'response' => null, ) )
}
/** JSS */
public function opsd_js_load_files( $where_to_load ) {
$in_footer = true;
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) {
wp_enqueue_script( 'opsd-dismiss', opsd_plugin_url( '/core/any/js/dismiss.js' ), array( 'opsd-global-vars' ), '1.1', $in_footer );
}
}
/** CSS */
public function opsd_enqueue_css_files( $where_to_load ) {
if ( ( is_admin() ) && ( in_array( $where_to_load, array( 'admin', 'both' ) ) ) ) {
wp_enqueue_style( 'opsd-dismiss', opsd_plugin_url( '/core/any/css/dismiss.css' ), array(), OPSD_VERSION_NUM );
}
}
/** Check if this section dismissed or not.
*
* @param string $section_html_id
* @return boolean
*/
public function is_dismissed( $section_html_id ) {
if ( '1' == get_user_option( 'opsd_win_' . $section_html_id ) )
return true;
else
return false;
}
}
function opsd_dismiss() {
return OPSD_Dismiss::init();
}
opsd_dismiss(); // Run
/** Check if specific section dismissed or not
*
* @param type $section_html_id
* @return boolean
*/
function opsd_section_is_dismissed( $section_html_id ) {
$opsd_dismiss = opsd_dismiss();
return $opsd_dismiss->is_dismissed( $section_html_id );
}
/** Show dismiss X button
*
* @param string $title
* @param array $attributes_arr - array of attributes, like: array( 'class' => 'opsd_dismiss' )
* @param bool $echo
* @return string of dismiss button
*/
function opsd_x_dismiss_button( $title = '&times;', $attributes_arr = array(), $echo = true ) {
$defaults = array(
'style' => ''
, 'class' => 'opsd_dismiss'
, 'title' => esc_js( __( 'Close', 'secure-downloads' ) )
);
$attributes_arr = wp_parse_args( $attributes_arr, $defaults );
$attr_echo = array();
foreach ( $attributes_arr as $attr_name => $attr_value ) {
$attr_echo[] = esc_attr( $attr_name ) . '="' . esc_attr( $attr_value ) . '"';
}
$attr_echo = implode( ' ', $attr_echo );
if ( ! $echo ) { ob_start(); }
?><a href="javascript:void(0)" <?php echo $attr_echo; ?> ><?php echo $title; ?></a><?php
if ( ! $echo ) { return ob_get_clean(); }
}

View File

@@ -0,0 +1,385 @@
<?php /**
* @version 1.0
* @description Notices Class
* @category Show system Notices
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2015-11-13
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Showing our system notices in admin panel */
class OPSD_Notices {
function __construct() {
// Hooks for showing notices only at specific admin pages
add_action( 'opsd_hook_opsd_page_header', array( $this, 'show_system_notices' ) );
add_action( 'opsd_settings_after_header', array( $this, 'show_system_notices' ) );
}
/** Check and show some system messages
*
* @param array $page_arr array( 'page' => $this->in_page() ) || array( 'page' => $this->in_page(), 'subpage' => 'emails_settings' )
*/
public function show_system_notices( $page_arr ) {
if ( ! in_array( $page_arr, array( 'opsd-files', 'opsd', 'opsd-settings' ) ) )
return false;
///////////////////////////////////////////////////////////
$notice_id = 'opsd_system_notice_nginix';
///////////////////////////////////////////////////////////
if ( ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) )
&& ( stristr( $_SERVER[ 'SERVER_SOFTWARE' ], 'nginx' ) !== false )
&& ( ! opsd_section_is_dismissed( $notice_id ) )
//|| true
) {
// Rules for NGINX
$opsd_upload = opsd_upload();
$upload_path = $opsd_upload->get_protected_dir();
if ( isset( $_SERVER[ 'DOCUMENT_ROOT' ] ) )
$upload_path = str_replace( $_SERVER[ 'DOCUMENT_ROOT' ], '', $upload_path ); // replace document root because nginx uses path from document root
$nx_rules = "location " . $upload_path . " {\n deny all; \n return 403;\n}";
// echo '<div class="error notice is-dismissible dlm-notice" id="nginx_rules" data-nonce="' . wp_create_nonce( 'opsd_dismiss_notice-nginx_rules' ) . '">';
?><div id="<?php echo $notice_id; ?>"
class="opsd_system_notice opsd_is_dismissible opsd_is_hideable updated error"
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( __( 'Your download files are not protected with .htaccess file, because your server is running on NGINX. To protect these files, you must add the following rules to your nginx config to disable direct file access: %s', 'secure-downloads' )
, '<br/><pre style="line-height: 1.55em;pre-wrap;"><code>' . $nx_rules . '</code></pre>' );
//FixIn:1.1.1
printf( __( 'By default the file is named %s and placed in the %s directory. (For the open source NGINX product, the location depends on the package system used to install NGINX and the operating system. It is typically one of %s)', 'secure-downloads' )
, '<code>nginx.conf</code>'
, '<code>/etc/nginx</code>'
, '<code>/usr/local/nginx/conf</code>, <code>/etc/nginx</code>, <code>/usr/local/etc/nginx</code>.'
);
echo ' ';
printf( __( 'Please contact your server administrator or support of hosting company about more details of your server configuration.', 'secure-downloads' ) );
?></div><?php
} else {
//FixIn:1.1.1
$notice_id = 'opsd_system_notice_nginix_recheck';
if ( ! opsd_section_is_dismissed( $notice_id ) ) {
// // Rules for NGINX
// $opsd_upload = opsd_upload();
// $upload_path = $opsd_upload->get_protected_dir();
// if ( isset( $_SERVER[ 'DOCUMENT_ROOT' ] ) )
// $upload_path = str_replace( $_SERVER[ 'DOCUMENT_ROOT' ], '', $upload_path ); // replace document root because nginx uses path from document root
// $nx_rules = "location " . $upload_path . " {\n deny all; \n return 403;\n}";
// echo '<div class="error notice is-dismissible dlm-notice" id="nginx_rules" data-nonce="' . wp_create_nonce( 'opsd_dismiss_notice-nginx_rules' ) . '">';
?><div id="<?php echo $notice_id; ?>"
class="opsd_system_notice opsd_is_dismissible opsd_is_hideable updated notice-warning"
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();
//FixIn: 1.1.2.6
// Rules for NGINX
$opsd_upload = opsd_upload();
$upload_path2 = $opsd_upload->get_protected_dir();
if ( isset( $_SERVER[ 'DOCUMENT_ROOT' ] ) )
$upload_path2 = str_replace( $_SERVER[ 'DOCUMENT_ROOT' ], '', $upload_path2 ); // replace document root because nginx uses path from document root
$nx_rules = "location " . $upload_path2 . " {\n deny all; \n return 403;\n}";
echo '<strong>' . __( 'Note!', 'secure-downloads' ) . '</strong> ';
printf( __( 'If your server is running on NGINX or your server use NGINX as proxy server for managing static content like images or zip files, then some or all your download files are not protected with .htaccess file.', 'secure-downloads' )
, '<br/><pre style="line-height: 1.55em;pre-wrap;"><code>' . $nx_rules . '</code></pre>' );
echo ' <br/>';
printf( __( 'Please contact your server administrator or support of hosting company about more details of your server configuration.', 'secure-downloads' ) );
?></div><?php
}
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
$notice_id = 'opsd_system_notice_free_instead_paid';
///////////////////////////////////////////////////////////
if ( opsd_is_updated_paid_to_free()
&& ( ! opsd_section_is_dismissed( $notice_id ) )
// || true
) {
?><div id="<?php echo $notice_id; ?>"
class="opsd_system_notice opsd_is_dismissible opsd_is_hideable updated notice-warning"
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 updated your paid version of Secure Downloads by free version or update process failed. You can request the new update of your paid version at %1sthis page%2s.', 'secure-downloads' )
, '<a href="https://oplugins.com/plugins/secure-downloads/request-update/" target="_blank">', '</a>' );
?></div><?php
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
$notice_id = 'opsd-panel-get-started';
///////////////////////////////////////////////////////////
if ( ! opsd_section_is_dismissed( $notice_id ) ) {
?>
<style type="text/css" media="screen">
/* OPSD Welcome Panel */
.opsd-panel .welcome-panel {
background: linear-gradient(to top, #F5F5F5, #FAFAFA) repeat scroll 0 0 #F5F5F5;
border-color: #DFDFDF;
position: relative;
overflow: auto;
margin: 5px 0 20px;
padding: 23px 10px 12px;
border-width: 1px;
border-style: solid;
border-radius: 3px;
font-size: 13px;
line-height: 2.1em;
}
.opsd-panel .welcome-panel h3 {
margin: 0;
font-size: 21px;
font-weight: 400;
line-height: 1.2;
}
.opsd-panel .welcome-panel h4 {
margin: 1.33em 0 0;
font-size: 13px;
font-weight: 600;
}
.opsd-panel .welcome-panel a{
color:#21759B;
}
.opsd-panel .welcome-panel .about-description {
font-size: 16px;
margin: 0;
}
.opsd-panel .welcome-panel .welcome-panel-close {
position: absolute;
top: 5px;
right: 10px;
padding: 8px 3px;
font-size: 13px;
text-decoration: none;
line-height: 1;
}
.opsd-panel .welcome-panel .welcome-panel-close:before {
content: ' ';
position: absolute;
left: -12px;
width: 10px;
height: 100%;
background: url('../wp-admin/images/xit.gif') 0 7% no-repeat;
}
.opsd-panel .welcome-panel .welcome-panel-close:hover:before {
background-position: 100% 7%;
}
.opsd-panel .welcome-panel .button.button-hero {
margin: 15px 0 3px;
}
.opsd-panel .welcome-panel-content {
margin-left: 13px;
max-width: 1500px;
}
.opsd-panel .welcome-panel .welcome-panel-column-container {
clear: both;
overflow: hidden;
position: relative;
}
.opsd-panel .welcome-panel .welcome-panel-column {
width: 32%;
min-width: 200px;
float: left;
}
.ie8 .opsd-panel .welcome-panel .welcome-panel-column {
min-width: 230px;
}
.opsd-panel .welcome-panel .welcome-panel-column:first-child {
width: 36%;
}
.opsd-panel .welcome-panel-column p {
margin-top: 7px;
}
.opsd-panel .welcome-panel .welcome-icon {
background: none;
display: block;
padding: 2px 0 8px 2px;
}
.opsd-panel .welcome-panel .welcome-add-page {
background-position: 0 2px;
}
.opsd-panel .welcome-panel .welcome-edit-page {
background-position: 0 -90px;
}
.opsd-panel .welcome-panel .welcome-learn-more {
background-position: 0 -136px;
}
.opsd-panel .welcome-panel .welcome-comments {
background-position: 0 -182px;
}
.opsd-panel .welcome-panel .welcome-view-site {
background-position: 0 -274px;
}
.opsd-panel .welcome-panel .welcome-widgets-menus {
background-position: 1px -229px;
line-height: 14px;
}
.opsd-panel .welcome-panel .welcome-write-blog {
background-position: 0 -44px;
}
.opsd-panel .welcome-panel .welcome-panel-column ul {
margin: 0.8em 1em 1em 0;
}
.opsd-panel .welcome-panel .welcome-panel-column li {
line-height: 1.7em;
list-style-type: none;
margin:0;
padding:0;
}
@media screen and (max-width: 870px) {
.opsd-panel .welcome-panel .welcome-panel-column,
.opsd-panel .welcome-panel .welcome-panel-column:first-child {
display: block;
float: none;
width: 100%;
}
.opsd-panel .welcome-panel .welcome-panel-column li {
display: inline-block;
margin-right: 13px;
}
.opsd-panel .welcome-panel .welcome-panel-column ul {
margin: 0.4em 0 0;
}
.opsd-panel .welcome-panel .welcome-icon {
padding-left: 25px;
}
}
</style>
<div id="<?php echo $notice_id ?>"
class="opsd-panel opsd_is_dismissible opsd_is_hideable "
data-nonce="<?php echo wp_create_nonce( $nonce_name = $notice_id . '_opsdnonce' ); ?>"
data-user-id="<?php echo get_current_user_id(); ?>"
><div class="welcome-panel"><?php
opsd_x_dismiss_button( '&times;', array( 'style' => 'font-size:1.5em;margin-top:-0.8em;' ) );
?>
<div class="welcome-panel-content">
<p class="about-description"><?php _e( 'We&#8217;ve assembled some links to get you started:', 'secure-downloads'); ?></p>
<div class="welcome-panel-column-container">
<div class="welcome-panel-column">
<h4><?php _e( 'Upload your files to secure direcory', 'secure-downloads'); ?>:</h4>
<ul>
<li><div class="welcome-icon"><?php
printf( __( 'Open %s menu page', 'secure-downloads')
, '<a href="' . admin_url( 'admin.php?page=opsd-files' ) . '">'
. '<strong>' . 'Secure Downloads > ' . __( 'Files', 'secure-downloads' ) . '</strong>'
. '</a>'
);
?></div></li>
<li><div class="welcome-icon"><?php
echo '1. ' . sprintf( __( 'Click on %s"Add New"%s button and upload your files.', 'secure-downloads' ), '<strong>', '</strong>' );
?></div></li>
<li><div class="welcome-icon"><?php
echo '2. ' . sprintf( __( 'Enter Title, Version Number and Description at %s"Attachment details"%s section.', 'secure-downloads' ), '<strong>', '</strong>' );
?></div></li>
<li><div class="welcome-icon"><?php
echo '3. ' . sprintf( __( 'Select one or multiple files, click insert button and Save changes.', 'secure-downloads' ) );
?></div></li>
</ul>
</div>
<div class="welcome-panel-column">
<h4><?php _e( 'Next Steps', 'secure-downloads'); ?>.</h4>
<ul>
<li><div class="welcome-icon"><?php
printf( __( 'Open %s menu page and %s send predefined email with secure link %s to your customer or simply %s generate secure link %s', 'secure-downloads')
, '<a href="' . admin_url( 'admin.php?page=opsd' ) . '">'
. '<strong>' . __( 'Secure Links', 'secure-downloads' ) . '</strong>'
. '</a>'
, '<strong>', '</strong>'
, '<strong>', '</strong>.'
);
?></div></li>
<li><div class="welcome-icon"><?php
printf( __( 'Configure different options in %sSettings%s.' , 'secure-downloads'),
'<a href="' . esc_url( opsd_get_settings_url() ) . '">', '</a>' );
?></div></li>
<li><div class="welcome-icon"><?php
printf( __( 'Configure your predefined %sEmail Templates%s.', 'secure-downloads'),
'<a href="' . esc_url( opsd_get_settings_url() . '&tab=email' ) . '">', '</a>' );
?></div></li>
</ul>
</div>
<div class="welcome-panel-column welcome-panel-last">
<h4><?php _e( 'Tips', 'secure-downloads'); ?></h4>
<ul>
<li><div class="welcome-icon"><?php
printf( __( 'You can easy reorder files list at %s page.', 'secure-downloads')
, '<a href="' . admin_url( 'admin.php?page=opsd-files&tab=files-sortable' ) . '">'
. '<strong>' . __( 'Sortable List', 'secure-downloads' ) . '</strong>'
. '</a>'
);
?></div></li>
<li><div class="welcome-icon"><?php
echo '<strong>' . __( 'Note', 'secure-downloads' ) . '</strong>. '
. __( 'You can use line with simple text without CSV separators for definition of sections in file list.', 'secure-downloads')
;
?></div></li>
<li><div class="welcome-icon"><?php
printf( __( 'Still having questions? Contact %sSupport%s.', 'secure-downloads'),
'<a href="https://oplugins.com/support/" target="_blank">',
'</a>' );
?></div></li>
<li><div class="welcome-icon"><?php
printf( __( 'Do you require new feature? Send your %ssuggestion%s to us.', 'secure-downloads'),
'<a href="mailto:newfeature@oplugins.com?Subject=Secure%20Downloads" target="_blank">',
'</a>' );
?></div></li>
</ul>
</div>
</div>
<div class="welcome-icon welcome-widgets-menus" style="text-align:right;font-style:italic;"><?php
printf( __( 'Need even more functionality? Check %s higher versions %s', 'secure-downloads'),
'<a href="https://oplugins.com/plugins/secure-downloads/#premium" target="_blank">',
'</a>'
); ?>
</div>
</div>
<?php
?></div></div><?php
}
}
}
new OPSD_Notices(); // Run

View File

@@ -0,0 +1,2 @@
<?php
// Silence is golden.

View File

@@ -0,0 +1,268 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Activation / Deactivation
* @category Functions
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
* @modified 2016-03-17
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Activation & Deactivation of Secure Downloads */
class OPSD_ItemInstall extends OPSD_Install {
/** Overload Secure Downloads option names and some other parameters */
public function get_init_option_names() {
add_opsd_action( 'opsd_activate_user', array( $this, 'opsd_activate') ); // Hook for MU User activation
return array(
'option-version_num' => 'opsd_version_num'
, 'option-is_delete_if_deactive' => 'opsd_is_delete_if_deactive'
, 'option-activation_process' => 'opsd_activation_process'
, 'transient-opsd_activation_redirect' => '_opsd_activation_redirect'
, 'message-delete_data' => '<strong>' . __('Warning!', 'secure-downloads') . '</strong> '
. __('All plugin data will be deleted when the plugin is deactivated.', 'secure-downloads')
. '<br />'
. sprintf( __('If you want to save your plugin data, please uncheck the %s"Delete data"%s at the' , 'secure-downloads')
, '<strong>', '</strong>')
. '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'opsd-settings' ), 'admin.php' ) ) )
. '#opsd_general_settings_uninstall_metabox"> ' . __('settings page', 'secure-downloads') . '.'
. ' </a>'
, 'link_settings' => '<a href="' . esc_url( admin_url( add_query_arg( array( 'page' => 'opsd-settings' ), 'admin.php' ) ) )
. '">'.__("Settings", 'secure-downloads').'</a>'
, 'link_whats_new' => ''
);
}
/** Check if was updated from lower to high version */
public function is_update_from_lower_to_high_version() {
$is_make_activation = false;
// Check conditions for different version about Upgrade
if ( ( class_exists( 'opsd_personal' ) ) && ( ! opsd_is_table_exists( 'itemtypes' ) ) )
$is_make_activation = true;
return $is_make_activation;
}
}
////////////////////////////////////////////////////////////////////////////////
// A c t i v a t e & D e a c t i v a t e
////////////////////////////////////////////////////////////////////////////////
/** Activation */
function opsd_activate() {
// Check for blank data install
$opsd_secret_key = get_opsd_option( 'opsd_secret_key' );
if ( empty( $opsd_secret_key ) )
$is_first_time_install = true;
else
$is_first_time_install = false;
make_opsd_action( 'opsd_before_activation' );
opsd_load_translation();
$version = get_opsd_version();
$is_demo = opsd_is_this_demo();
////////////////////////////////////////////////////////////////////////////
// Options
////////////////////////////////////////////////////////////////////////////
$default_options_to_add = opsd_get_default_options();
foreach ( $default_options_to_add as $default_option_name => $default_option_value ) {
add_opsd_option( $default_option_name, $default_option_value );
}
// Check for blank data install
if ( $is_first_time_install )
opsd_create_blank_files();
////////////////////////////////////////////////////////////////////////////
// DB Tables
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Other versions Activation
////////////////////////////////////////////////////////////////////////////
make_opsd_action( 'opsd_other_versions_activation' );
make_opsd_action( 'opsd_after_activation' );
}
add_opsd_action( 'opsd_activation', 'opsd_activate' );
// Deactivate
function opsd_deactivate() {
////////////////////////////////////////////////////////////////////////////
// Options
////////////////////////////////////////////////////////////////////////////
$default_options_to_add = opsd_get_default_options();
foreach ( $default_options_to_add as $default_option_name => $default_option_value) {
delete_opsd_option( $default_option_name );
}
////////////////////////////////////////////////////////////////////////////
// Widgets
////////////////////////////////////////////////////////////////////////////
delete_opsd_option( 'opsd_activation_redirect_for_version' );
////////////////////////////////////////////////////////////////////////////
// DB Tables
////////////////////////////////////////////////////////////////////////////
global $wpdb;
// $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}opsd" );
// Delete all users item windows states
if ( false === $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%opsd_%'" ) ){ // All users data
debuge_error('Error during deleting user meta at DB',__FILE__,__LINE__);
die();
}
////////////////////////////////////////////////////////////////////////////
// Other versions Deactivation
////////////////////////////////////////////////////////////////////////////
make_opsd_action('opsd_other_versions_deactivation');
}
add_opsd_action( 'opsd_deactivation', 'opsd_deactivate' );
/** Default Options
*
* $option_name = '';
* $options_for_delete = opsd_get_default_options( $option_name, $is_get_multiuser_general_options );
*/
function opsd_get_default_options( $option_name = '' ) {
$is_demo = opsd_is_this_demo();
$default_options = array();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// General Settings
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$default_options[ 'opsd_download_url_path' ] = '';
$default_options[ 'opsd_protected_directory_name_level1' ] = 'opsd_' . wp_generate_password( 20, false, false );
$default_options[ 'opsd_secret_key' ] = wp_generate_password( 30, false, false );
$default_options[ 'opsd_defualt_expiration' ] = '+24 hours';
$default_options[ 'opsd_defualt_iplock' ] = '';
// URLs
$default_options[ 'opsd_url_wrong_hash' ] = '';
$default_options[ 'opsd_url_download_expired' ] = '';
$default_options[ 'opsd_url_ip_not_valied' ] = '';
$default_options[ 'opsd_url_file_not_exist' ] = '';
$default_options[ 'opsd_url_error_opening_file' ] = '';
// Miscellaneous
$default_options[ 'opsd_csv_separator' ] = ',';
$default_options[ 'opsd_date_format' ] = get_option( 'date_format' );
$default_options[ 'opsd_time_format' ] = get_option( 'time_format' );
// Advanced
$default_options[ 'opsd_is_not_load_bs_script_in_admin' ] = 'Off';
/**
$default_options[ 'opsd_is_not_load_bs_script_in_client' ] = 'Off';
$default_options[ 'opsd_is_load_js_css_on_specific_pages' ] = 'Off';
$default_options[ 'opsd_pages_for_load_js_css' ] = '';
*/
// User permissions
$default_options[ 'opsd_user_role_master' ] = ( $is_demo ) ? 'subscriber' : 'editor';
$default_options[ 'opsd_user_role_addnew' ] = ( $is_demo ) ? 'subscriber' : 'editor';
$default_options[ 'opsd_user_role_settings' ] = ( $is_demo ) ? 'subscriber' : 'editor';
// Position
$default_options[ 'opsd_menu_position' ] = ( $is_demo ) ? 'top' : 'top';
// Uninstall
$default_options[ 'opsd_is_delete_if_deactive' ] = ($is_demo) ? 'On' : 'Off';
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Emails
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$user_info = array( 'name' => '' );
if ( is_user_logged_in() ) {
$user_data = get_userdata( get_current_user_id() );
$user_info['name'] = ( $user_data ) ? $user_data->display_name : '';
}
$email_settings = array();
$email_settings['enabled'] = 'On';
$email_settings['copy_to_admin'] = 'On';
$email_settings['from'] = get_option( 'admin_email' );
$email_settings['from_name'] = $user_info['name'];
$email_settings['subject'] = sprintf( __( 'Delivery of %s', 'secure-downloads'), '[product_title] [product_version]' );
$email_settings['content'] = sprintf( __( 'Hello. %sThank you for requesting %s To download %s click the link below: %s Thank you, %s', 'secure-downloads' )
, '<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]' );
$email_settings['header_content'] = '';
$email_settings['footer_content'] = '';
$email_settings['template_file'] = 'plain';
$email_settings['base_color'] = '#557da1';
$email_settings['background_color'] = '#f5f5f5';
$email_settings['body_color'] = '#fdfdfd';
$email_settings['text_color'] = '#505050';
$email_settings['email_content_type'] = 'html';
$default_options[ 'opsd_email_link_user' ] = $email_settings;
// Just modify some params in previos email
$email_settings[ 'to' ] = $email_settings['from'];
$email_settings[ 'to_name' ] = $email_settings['from_name'];
$email_settings['subject'] = sprintf( __( 'Download notification of %s', 'secure-downloads'), '[product_title] [ [product_id] ]' );
$email_settings['content'] = sprintf( __( 'Hi. %s The %s have been downloaded. %s ===== User Info ===== %s To: %s IP: %s User agent: %s Request url: %s ====================== %s ===== Product Summary ===== %s Expire at %s ====================== %s', 'secure-downloads' )
, '<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>'
);
$default_options[ 'opsd_email_download_notification' ] = $email_settings;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// C S V P R O D U C T S - F I L E S
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$default_options[ 'opsd_products_csv' ] = '';
if ( ! empty( $option_name ) ) {
if ( isset( $default_options[ $option_name ] ) )
return $default_options[ $option_name ]; // Return 1 option
else
return false; // Option does NOT exist
} else {
return $default_options; // Return ALL
}
}

View File

@@ -0,0 +1,151 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Ajax Responder
* @category Items
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2014.05.26
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////
// S u p p o r t f u n c t i o n s f o r A j a x ///////////////
////////////////////////////////////////////////////////////////////////////////
// Verify the nonce.
function opsd_check_nonce_in_admin_panel( $action_check = 'opsd_ajax_admin_nonce' ){
$nonce = ( isset($_REQUEST['opsd_nonce']) ) ? $_REQUEST['opsd_nonce'] : '';
if ( '' === $nonce ) return false; // Its was request from some other plugin //FixIn: 1.1.4.1
if ( ! wp_verify_nonce( $nonce, $action_check ) ) { // This nonce is not valid.
?>
<script type="text/javascript">
jQuery("#ajax_respond").after( "<div class='wpdevelop'><div class='alert alert-warning alert-danger'><?php
printf(__('%sError!%s Request do not pass security check! Please refresh the page and try one more time.' , 'secure-downloads'),'<strong>','</strong>');
?></div></div>" );
if ( jQuery("#ajax_message").length )
jQuery("#ajax_message").slideUp();
</script>
<?php
die;
}
return true; //FixIn: 1.1.4.1
}
// Check and (re)Load specific Locale for the Ajax request - based on "admin_init" hook
function opsd_check_locale_for_ajax() {
add_opsd_filter('opsd_check_for_active_language', 'opsd_check_for_active_language'); // Add Hook for ability to check the content for active lanaguges
if (isset($_POST['opsd_active_locale'])) { // Reload locale according request parameter
global $l10n;
if (isset($l10n['secure-downloads'])) unset($l10n['secure-downloads']);
if(! defined('OPSD_RELOAD') ) define('OPSD_RELOAD', esc_js( $_POST['opsd_active_locale'] ) );
// Reload locale settings, its required for the correct dates format
if (isset($l10n['default'])) unset($l10n['default']); // Unload locale
add_filter('locale', 'opsd_get_locale',999); // Set filter to load the locale of the Secure Downloads
load_default_textdomain(); // Load default locale
global $wp_locale;
$wp_locale = new WP_Locale(); // Reload class
opsd_load_locale(OPSD_RELOAD);
}
}
////////////////////////////////////////////////////////////////////////////////
// A j a x H o o k s f o r s p e c i f i c A c t i o n s /////
////////////////////////////////////////////////////////////////////////////////
function opsd_ajax_USER_SAVE_WINDOW_STATE() {
// if ( ! opsd_check_nonce_in_admin_panel() ) return false; //FixIn: 1.1.4.1
// update_user_option($_POST['user_id'],'opsd_win_' . $_POST['window'] ,$_POST['is_closed']);
if ( ! opsd_check_nonce_in_admin_panel() ) return false; //FixIn: 1.1.4.1
update_user_option( (int) $_POST['user_id'], 'opsd_win_' . esc_attr( $_POST['window'] ) , (int) $_POST['is_closed'] );
}
/** Save Custom User Data */
function opsd_ajax_USER_SAVE_CUSTOM_DATA() {
if ( ! opsd_check_nonce_in_admin_panel() ) return false; //FixIn: 1.1.4.1
/* Exmaple of $_POST:
[data_name] => add_opsd_calendar_options
[data_value] => calendar_months_count=1&calendar_months_num_in_1_row=1&calendar_width=500px&calendar_cell_height
*/
$post_param = explode( '&', $_POST['data_value'] ); // "&" was set by jQuery.param( data_params ) in client side.
$data_to_save = array();
foreach ( $post_param as $param ) {
$param_data = explode( '=', $param );
$data_to_save[ $param_data[0] ] = ( isset( $param_data[1] ) ) ? esc_attr( $param_data[1] ) : '';
}
/* Exmaple:
Array
(
[calendar_months_count] => 1
[calendar_months_num_in_1_row] => 1
[calendar_width] => 500px
[calendar_cell_height] =>
)
*/
// Save Custom User Data
update_user_option( (int) $_POST['user_id'], 'opsd_custom_' . esc_attr( $_POST['data_name'] ) , serialize( $data_to_save ) );
?> <script type="text/javascript">
var my_message = '<?php echo html_entity_decode( esc_js( __('Saved' , 'secure-downloads') ),ENT_QUOTES) ; ?>';
opsd_admin_show_message( my_message, 'success', 1000 );
<?php if ( ! empty( $_POST['is_reload'] ) == 1 ) { ?>
setTimeout(function ( ) {location.reload(true);} ,1500);
<?php } ?>
</script> <?php
die();
}
////////////////////////////////////////////////////////////////////////////////
// R u n A j a x //////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
if ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) {
// Reload Locale if its required
add_action( 'admin_init', 'opsd_check_locale_for_ajax' );
// Hooks list
$actions_list = array(
'USER_SAVE_WINDOW_STATE' => 'admin'
,'USER_SAVE_CUSTOM_DATA' => 'admin'
);
foreach ($actions_list as $action_name => $action_where) {
if ( ( isset($_POST['action']) ) && ( $_POST['action'] == $action_name ) ){
if ( ( $action_where == 'admin' ) || ( $action_where == 'both' ) )
add_action( 'wp_ajax_' . $action_name, 'opsd_ajax_' . $action_name); // Admin & Client (logged in usres)
if ( ( $action_where == 'both' ) || ( $action_where == 'client' ) )
add_action( 'wp_ajax_nopriv_' . $action_name, 'opsd_ajax_' . $action_name); // Client (not logged in)
}
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Define Constants
* @category Items
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2014.05.17
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// USERS CONFIGURABLE CONSTANTS //////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!defined('OPSD_SHOW_INFO_IN_FORM')) define('OPSD_SHOW_INFO_IN_FORM', false ); // This feature can impact to the performance
if (!defined('OPSD_SHOW_OPSD_NOTES')) define('OPSD_SHOW_OPSD_NOTES', false ); // Set notes of the specific item visible by default.
if (!defined('OPSD_CUSTOM_FORMS_FOR_REGULAR_USERS')) define('OPSD_CUSTOM_FORMS_FOR_REGULAR_USERS', false ); // Only for MultiUser version
if (!defined('OPSD_SHOW_DEPOSIT_AND_TOTAL_PAYMENT')) define('OPSD_SHOW_DEPOSIT_AND_TOTAL_PAYMENT', false ); // Show both deposit and total cost payment forms, after visitor submit item. Important! Please note, in this case at admin panel for item will be saved deposit cost and notes about deposit, do not depend from the visitor choise of this payment. So you need to check each such payment manually.
if (!defined('OPSD_STRICTLY_FROM_EMAILS')) define('OPSD_STRICTLY_FROM_EMAILS', true ); // If true, plugin will send emails with "From" address that defined in "From" field at item > Settings > Emails page. Otherwise (if false), when sending the copy of Confirmation email to admin, sends a "from" field of email not the email of server, but email from the person, who made reservation. Its useful for "reply to this emails", but when receiving such email, Yahoo mail for instance rejects it, and google mail puts a warning about fishing etc.
if (!defined('OPSD_IS_SEND_EMAILS_ON_COST_CHANGE')) define('OPSD_IS_SEND_EMAILS_ON_COST_CHANGE', false ); //FixIn: 6.0.1.7 // Is send modification email, if cost was changed in admin panel
if (!defined('OPSD_LAST_CHECKOUT_DAY_AVAILABLE')) define('OPSD_LAST_CHECKOUT_DAY_AVAILABLE', false ); //FixIn: 6.2.3.6 // Its will remove last selected day of item during saving it as item.
if (!defined('OPSD_PAYMENT_FORM_ONLY_IN_REQUEST')) define('OPSD_PAYMENT_FORM_ONLY_IN_REQUEST', false ); // Its will show payment form only in payment request during sending from item Listing page and do not show payment form after visitor made the item.
if (!defined('OPSD_AUTO_APPROVE_WHEN_ZERO_COST')) define('OPSD_AUTO_APPROVE_WHEN_ZERO_COST', false ); // Auto approve item, if the cost of item == 0
if (!defined('OPSD_CHECK_LESS_THAN_PARAM_IN_SEARCH')) define('OPSD_CHECK_LESS_THAN_PARAM_IN_SEARCH', false ); // Check in search results custom fields parameters relative to less than in search form, and not only equal.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// SYSTEM CONSTANTS //////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!defined('OPSD_MINOR_UPDATE')) define('OPSD_MINOR_UPDATE', true );
if (!defined('IS_USE_OPSD_CACHE')) define('IS_USE_OPSD_CACHE', true );
if (!defined('OPSD_DEBUG_MODE')) define('OPSD_DEBUG_MODE', false );
if (!defined('OPSD_MIN')) define('OPSD_MIN', false );//TODO: Finish with this contstant, right now its not working correctly with TRUE status
if (!defined('OPSD_RESPONSE')) define('OPSD_RESPONSE', false );

View File

@@ -0,0 +1,171 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Core Functions
* @category Functions
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 29.09.2015
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////
// Internal plugin action hooks system ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
global $opsd_action, $opsd_filter;
function add_opsd_filter($filter_type, $filter) {
global $opsd_filter;
$args = array();
if ( is_array($filter) && 1 == count($filter) && is_object($filter[0]) ) // array(&$this)
$args[] =& $filter[0];
else
$args[] = $filter;
for ( $a = 2; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);
if ( is_array($opsd_filter) )
if ( isset($opsd_filter[$filter_type]) ) {
if ( is_array($opsd_filter[$filter_type]) )
$opsd_filter[$filter_type][]= $args;
else
$opsd_filter[$filter_type]= array($args);
} else
$opsd_filter[$filter_type]= array($args);
else
$opsd_filter = array( $filter_type => array( $args ) ) ;
}
function remove_opsd_filter($filter_type, $filter) {
global $opsd_filter;
if ( isset($opsd_filter[$filter_type]) ) {
for ($i = 0; $i < count($opsd_filter[$filter_type]); $i++) {
if ( $opsd_filter[$filter_type][$i][0] == $filter ) {
$opsd_filter[$filter_type][$i] = null;
return;
}
}
}
}
function apply_opsd_filter($filter_type) {
global $opsd_filter;
$args = array();
for ( $a = 1; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);
if ( count($args) > 0 )
$value = $args[0];
else
$value = false;
if ( is_array($opsd_filter) )
if ( isset($opsd_filter[$filter_type]) )
foreach ($opsd_filter[$filter_type] as $filter) {
$filter_func = array_shift($filter);
$parameter = $args;
$value = call_user_func_array($filter_func,$parameter );
}
return $value;
}
function make_opsd_action($action_type) {
global $opsd_action;
$args = array();
for ( $a = 1; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);
if ( is_array($opsd_action) )
if ( isset($opsd_action[$action_type]) )
foreach ($opsd_action[$action_type] as $action) {
$action_func = array_shift($action);
$parameter = $action;
call_user_func_array($action_func,$args );
}
}
function add_opsd_action($action_type, $action) {
global $opsd_action;
$args = array();
if ( is_array($action) && 1 == count($action) && is_object($action[0]) ) // array(&$this)
$args[] =& $action[0];
else
$args[] = $action;
for ( $a = 2; $a < func_num_args(); $a++ )
$args[] = func_get_arg($a);
if ( is_array($opsd_action) )
if ( isset($opsd_action[$action_type]) ) {
if ( is_array($opsd_action[$action_type]) )
$opsd_action[$action_type][]= $args;
else
$opsd_action[$action_type]= array($args);
} else
$opsd_action[$action_type]= array($args);
else
$opsd_action = array( $action_type => array( $args ) ) ;
}
function remove_opsd_action($action_type, $action) {
global $opsd_action;
if ( isset($opsd_action[$action_type]) ) {
for ($i = 0; $i < count($opsd_action[$action_type]); $i++) {
if ( $opsd_action[$action_type][$i][0] == $action ) {
$opsd_action[$action_type][$i] = null;
return;
}
}
}
}
function get_opsd_option( $option, $default = false ) {
$u_value = apply_opsd_filter('opsd_get_option', 'no-values' , $option, $default );
if ( $u_value !== 'no-values' ) return $u_value;
return get_option( $option, $default );
}
function update_opsd_option ( $option, $newvalue ) {
$u_value = apply_opsd_filter('opsd_update_option', 'no-values' , $option, $newvalue );
if ( $u_value !== 'no-values' ) return $u_value;
return update_option($option, $newvalue);
}
function delete_opsd_option ( $option ) {
$u_value = apply_opsd_filter('opsd_delete_option', 'no-values' , $option );
if ( $u_value !== 'no-values' ) return $u_value;
return delete_option($option );
}
function add_opsd_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
$u_value = apply_opsd_filter('opsd_add_option', 'no-values' , $option, $value, $deprecated, $autoload );
if ( $u_value !== 'no-values' ) return $u_value;
return add_option( $option, $value , $deprecated , $autoload );
}

View File

@@ -0,0 +1,122 @@
<?php /**
* @version 1.0
* @package
* @category Core
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* //FixIn: 1.2.2.1
* @modified 2013.10.16, 2023-04-15
*/
class OPSD_CSS extends OPSD_JS_CSS{
public function define() {
$this->setType('css');
/*
// Exmaples of usage Font Avesome: http://fontawesome.io/icons/
$this->add( array(
'handle' => 'font-awesome',
'src' => OPSD_PLUGIN_URL . 'assets/libs/font-awesome-4.3.0/css/font-awesome.css' ,
'deps' => false,
'version' => '4.3.0',
'where_to_load' => array( 'admin' ),
'condition' => false
) );
// Exmaples of usage Font Avesome 3.2.1 (benefits of this version - support IE7): http://fontawesome.io/3.2.1/examples/
$this->add( array(
'handle' => 'font-awesome',
'src' => OPSD_PLUGIN_URL . '/assets/libs/font-awesome/css/font-awesome.css' ,
'deps' => false,
'version' => '3.2.1',
'where_to_load' => array( 'admin' ),
'condition' => false
) );
$this->add( array(
'handle' => 'font-awesome-ie7',
'src' => OPSD_PLUGIN_URL . '/assets/libs/font-awesome/css/font-awesome-ie7.css' ,
'deps' => array('font-awesome'),
'version' => '3.2.1',
'where_to_load' => array( 'admin' ),
'condition' => 'IE 7' // CSS condition. Exmaple: <!--[if IE 7]>
) );
*/
}
public function enqueue( $where_to_load ) {
if ( $where_to_load == 'admin' ) { // Admin CSS files
//FixIn: 1.2.2.1
wp_enqueue_style( 'wpdevelop-bts', opsd_plugin_url( '/assets/libs/bootstrap/css/bootstrap.css' ), array(), '3.3.5.1' );
wp_enqueue_style( 'wpdevelop-bts-theme', opsd_plugin_url( '/assets/libs/bootstrap/css/bootstrap-theme.css' ), array(), '3.3.5.1' );
// wp_enqueue_style('opsd-chosen', opsd_plugin_url( '/assets/libs/chosen/chosen.css' ), array(), OPSD_VERSION_NUM); //FixIn: 1.2.1
wp_enqueue_style( 'opsd-admin-support', opsd_plugin_url( '/core/any/css/admin-support.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-admin-menu', opsd_plugin_url( '/core/any/css/admin-menu.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-admin-toolbar', opsd_plugin_url( '/core/any/css/admin-toolbar.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-settings-page', opsd_plugin_url( '/core/any/css/settings-page.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-admin-listing-table', opsd_plugin_url( '/core/any/css/admin-listing-table.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-br-table', opsd_plugin_url( '/core/any/css/admin-br-table.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-admin-modal-popups', opsd_plugin_url( '/css/modal.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-admin-pages', opsd_plugin_url( '/css/admin.css' ), array(), OPSD_VERSION_NUM );
wp_enqueue_style( 'opsd-css-print', opsd_plugin_url( '/css/print.css' ), array(), OPSD_VERSION_NUM );
global $wp_version;
/* FixIn: 2.0.13.1 */
if ( ( version_compare( $wp_version, '5.3', '>=' ) )
|| ( version_compare( $wp_version, '5.3-RC2-46574', '>=' ) )
) {
/* The SVG is arrow-down-alt2 from Dashicons. */
$css = "
.wp-core-ui .wpdevelop .control-group .btn-toolbar .input-group > select,
.wp-core-ui .wpdevelop select.form-control {
background: #fff url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E') no-repeat right 5px top 55%;
padding: 2px 30px 2px 10px;
}
";
wp_add_inline_style( 'opsd-admin-support', $css );
}
//FixIn: 1.2.2.1
if ( ( $where_to_load != 'admin' ) || ( opsd_is_new_opsd_page() ) ) { // Client or Add New item page
wp_enqueue_style( 'opsd-client-pages', opsd_plugin_url( '/css/client.css' ), array(), OPSD_VERSION_NUM );
}
if ( ( $where_to_load != 'admin' ) || ( opsd_is_master_page() ) ) {
wp_enqueue_style( 'opsd-admin-popover', opsd_plugin_url( '/css/popover.css' ), array(), OPSD_VERSION_NUM );
}
wp_enqueue_style( 'opsd-calendar', opsd_plugin_url( '/css/calendar.css' ), array(), OPSD_VERSION_NUM );
} // Calendar Skins
do_action( 'opsd_enqueue_css_files', $where_to_load );
}
public function remove_conflicts( $where_to_load ) {
if ( opsd_is_master_page() ) {
if (function_exists('wp_dequeue_style')) {
/*
wp_dequeue_style( 'cs-alert' );
wp_dequeue_style( 'cs-framework' );
wp_dequeue_style( 'cs-font-awesome' );
wp_dequeue_style( 'icomoon' );
*/
wp_dequeue_style( 'chosen');
wp_dequeue_style( 'toolset-font-awesome-css' ); // Remove this script sitepress-multilingual-cms/res/css/font-awesome.min.css?ver=3.1.6, which is load by the "sitepress-multilingual-cms"
wp_dequeue_style( 'toolset-font-awesome' ); //FixIn: 5.4.5.8
}
}
}
}

View File

@@ -0,0 +1,173 @@
<?php
/**
* @version 1.1
* @package Any
* @category Dubug info showing
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 09.09.2015
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// D e b u g f u n c t i o n s ///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* Show values of the arguments list
*/
if (!function_exists ('debuge')) {
function debuge() {
$numargs = func_num_args();
$var = func_get_args();
$makeexit = is_bool( $var[count($var)-1] ) ? $var[ count($var) - 1 ]:false;
echo "<div><pre class='prettyprint linenums'>";
print_r ( $var );
echo "</pre></div>";
echo '<script type="text/javascript"> jQuery(".ajax_respond_insert, .ajax_respond").show(); </script>';
if ( $makeexit ) {
echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>';
exit;
}
}
}
/*
* Show Speed of the execution and number of queries.
*/
if (!function_exists ('debuge_speed')) {
function debuge_speed() {
echo '<div style="font-size:18px;float:right;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</div>';
}
}
/** Show error info
*/
if (!function_exists ('debuge_error')) {
function debuge_error( $msg , $file_name='', $line_num=''){
echo get_debuge_error( $msg , $file_name , $line_num );
}
}
if (!function_exists ('get_debuge_error')) {
function get_debuge_error( $msg , $file_name='', $line_num=''){
$ver_num = ( ! defined('OPSD_VERSION') ) ? '' : '|V:' . OPSD_VERSION ;
$last_db_error = '';
global $EZSQL_ERROR;
if (isset($EZSQL_ERROR[ (count($EZSQL_ERROR)-1)])) {
$last_db_error2 = $EZSQL_ERROR[ (count($EZSQL_ERROR)-1)];
if ( (isset($last_db_error2['query'])) && (isset($last_db_error2['error_str'])) ) {
$str = str_replace( array( '"', "'" ), '', $last_db_error2['error_str'] );
$query = str_replace( array( '"', "'" ), '', $last_db_error2['query'] );
$str = htmlspecialchars( $str, ENT_QUOTES );
$query = htmlspecialchars( $query , ENT_QUOTES );
$last_db_error = $str ;
$last_db_error .= '::<span style="color:#300;">'.$query.'</span>';
}
}
return $msg . '<br /><span style="font-size:11px;"> ['
. 'F:' . str_replace( dirname( $file_name ) , '' , $file_name )
. '| L:' . $line_num
. $ver_num
. '| DB:' . $last_db_error
. '] </span>' ;
}
}
// Usage: if ( function_exists ('opsd_check_post_key_max_number')) { opsd_check_post_key_max_number(); }
if ( ! function_exists ('opsd_check_post_key_max_number')) {
function opsd_check_post_key_max_number() {
/*
$post_max_totalname_length = intval( ( ini_get( 'suhosin.post.max_totalname_length' ) ) ? ini_get( 'suhosin.post.max_totalname_length' ) : '9999999' );
$request_max_totalname_length = intval( ( ini_get( 'suhosin.request.max_totalname_length' ) ) ? ini_get( 'suhosin.request.max_totalname_length' ) : '9999999' );
$post_max_name_length = intval( ( ini_get( 'suhosin.post.max_name_length' ) ) ? ini_get( 'suhosin.post.max_name_length' ) : '9999999' );
$request_max_varname_length = intval( ( ini_get( 'suhosin.request.max_varname_length' ) ) ? ini_get( 'suhosin.request.max_varname_length' ) : '9999999' );
*/
$php_ini_vars = array(
'suhosin.post.max_totalname_length'
, 'suhosin.request.max_totalname_length'
, 'suhosin.post.max_name_length'
, 'suhosin.request.max_varname_length'
);
foreach ( $_POST as $key_name => $post_value ) {
$key_length = strlen( $key_name );
foreach ( $php_ini_vars as $php_ini_var ) {
$php_ini_var_length = intval( ( ini_get( $php_ini_var ) ) ? ini_get( $php_ini_var ) : '9999999' );
if ( $key_length > $php_ini_var_length ) {
opsd_show_message_in_settings( 'Your php.ini configuration limited to '
. '<strong> '. $php_ini_var . ' = ' . $php_ini_var_length . '</strong>.'
. ' '
. 'Plugin require at least ' . ( intval( $key_length ) + 1 ). ', '
. 'for saving option: ' . '<strong>'. $key_name . '</strong>'
, 'error'
, __('Error' , 'secure-downloads') . '.' );
}
}
}
}
}
if ( ! function_exists( 'debuge_log' ) ) { //FixIn: 1.1.2.4
/** Write debuge log to file ../wp-content/upload/opsd_debug.log
*
* @param type $param
*/
function debuge_log( $param ) {
$content = "\n---\n"
. 'Log: [' . date_i18n( 'Y-m-d H:m:s' ) . ']'
. "\n---\n"
. str_replace( ',', "\n,", json_encode( $param ) );
// Install files and folders for uploading files and prevent hotlinking
$upload_dir = wp_upload_dir();
$files = array(
array(
'base' => $upload_dir['basedir'],
'file' => 'opsd_debug.log',
'content' => $content
)
);
foreach ( $files as $file ) {
if ( ( wp_mkdir_p( $file['base'] ) ) // Recursive directory creation based on full path.
//&& ( ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) // If file not exist
) {
// Append new lines to bottom (if we need to rewrite, then use 'w'
if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'a' ) ) {
fwrite( $file_handle, $file['content'] );
fclose( $file_handle );
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,325 @@
<?php
/**
* @version 1.1
* @package Secure Downloads
* @category Send Emails
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 15.09.2015
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////
// Emails
////////////////////////////////////////////////////////////////////////////////
/**
* Check email and format it
*
* @param string $emails
* @return string
*/
function opsd_validate_emails( $emails ) {
$emails = str_replace(';', ',', $emails);
if ( !is_array( $emails ) )
$emails = explode( ',', $emails );
$emails_list = array();
foreach ( (array) $emails as $recipient ) {
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
$recipient_name = '';
if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
if ( count( $matches ) == 3 ) {
$recipient_name = $matches[1];
$recipient = $matches[2];
}
} else {
// Check about correct format of email
if( preg_match( '/([\w\.\-_]+)?\w+@[\w\-_]+(\.\w+){1,}/im', $recipient, $matches ) ) { //FixIn: 8.7.7.2
$recipient = $matches[0];
}
}
$recipient_name = str_replace('"', '', $recipient_name);
$recipient_name = trim( wp_specialchars_decode( esc_html( stripslashes( $recipient_name ) ), ENT_QUOTES ) );
$emails_list[] = ( empty( $recipient_name ) ? '' : $recipient_name . ' ' )
. '<' . sanitize_email( $recipient ) . '>';
}
$emails_list = implode( ',', $emails_list );
return $emails_list;
}
function opsd_check_for_several_emails_in_form( $mail_recipients, $formdata, $bktype ) { // FixIn: 6.0.1.9
$possible_other_emails = explode('~',$formdata);
$possible_other_emails = array_map("explode", array_fill(0,count($possible_other_emails),'^'), $possible_other_emails);
$other_emails = array();
foreach ( $possible_other_emails as $possible_emails ) {
if ( ( $possible_emails[0] == 'email' )
//&& ( $possible_emails[1] != 'email' . $bktype )
&& ( ! empty($possible_emails[2]) )
)
$other_emails[]=$possible_emails[2];
}
if ( count( $other_emails ) > 1 ) {
$other_emails = implode(',',$other_emails);
$mail_recipients = $other_emails;
}
return $mail_recipients;
}
// N E W /////////////////////////////////////////////////////////////////////
/** Parse email and get Parts of Email - Name and Email
*
* @param string $email
* @return array [email] => beta@oplugins.com
[title] => item system
[original] => "Item system"
[original_to_show] => "Item system" <beta@oplugins.com>
*/
function opsd_get_email_parts( $email ) {
$email_to_parse = html_entity_decode( $email ); // Convert &quot; to " etc...
$pure_name = '';
$pure_email = '';
if( preg_match( '/(.*)<(.+)>/', $email_to_parse, $matches ) ) {
if ( count( $matches ) == 3 ) {
$pure_name = $matches[1];
$pure_email = $matches[2];
}
} else { // Check about correct format of email
if( preg_match( '/([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/im', $email_to_parse, $matches ) ) {
$pure_email = $matches[0];
}
}
$pure_name = trim( wp_specialchars_decode( esc_html( stripslashes( $pure_name ) ), ENT_QUOTES ) , ' "');
$return_email = array(
'email' => sanitize_email( $pure_email )
, 'title' => $pure_name
, 'original' => $email_to_parse
, 'original_to_show' => htmlentities( $email_to_parse ) // Convert " to &quot; etc...
);
return $return_email;
}
// Get Emails Help Shortcodes for Settings pages
function opsd_get_email_help_shortcodes( $skip_shortcodes = array() , $email_example = '') {
$fields = array();
$fields[] = '<strong>' . __('You can use following shortcodes in content of this template' , 'secure-downloads') . '</strong>';
$fields[] = sprintf( __( '%s - ID of product', 'secure-downloads' ) , '<code>[product_id]</code>' );
$fields[] = sprintf( __( '%s - title of product', 'secure-downloads' ) , '<code>[product_title]</code>' );
$fields[] = sprintf( __( '%s - version number of product', 'secure-downloads' ) , '<code>[product_version]</code>' );
$fields[] = sprintf( __( '%s - description of product', 'secure-downloads' ) , '<code>[product_description]</code>' );
$fields[] = sprintf( __( '%s - secure URL for product download','secure-downloads'), '<code>[product_link]</code>' );
$fields[] = sprintf( __( '%s - filename of the product', 'secure-downloads' ) , '<code>[product_filename]</code>' );
$fields[] = sprintf( __( '%s - the download size in a friendly format such as %s or %s', 'secure-downloads' ), '<code>[product_size]</code>', '500 KB', '3.45 MB' );
$fields[] = sprintf( __( '%s - expiry time in friendly format (e.g. 24 hours or 2 days etc)', 'secure-downloads' ), '<code>[product_expire_after]</code>' );
$fields[] = sprintf( __( '%s - exact expiry date and time (e.g. 2017-03-21 18:30)', 'secure-downloads' ), '<code>[product_expire_date]</code>' );
$fields[] = sprintf( __( '%s - complete product details including title, size, link etc', 'secure-downloads' ), '<code>[product_summary]</code>' );
$fields[] = '<hr/>';
$fields[] = sprintf( __( '%s - email, which was sent to secure link', 'secure-downloads' ), '<code>[link_sent_to]</code>' );
// $fields[] = sprintf( __( '%s - order', 'secure-downloads' ), '<code>[order]</code>' );
$fields[] = '<hr/>';
$fields[] = sprintf( __( '%s - website URL ', 'secure-downloads' ), '<code>[siteurl]</code>' );
$fields[] = sprintf( __( '%s - IP address of the user, who made this action ', 'secure-downloads' ), '<code>[remote_ip]</code>' );
$fields[] = sprintf( __( '%s - contents of the User-Agent header from the current request, if there is one ', 'secure-downloads' ), '<code>[user_agent]</code>' );
$fields[] = sprintf( __( '%s - address of the page (if any), where visitor make this action ', 'secure-downloads' ), '<code>[request_url]</code>' );
$fields[] = sprintf( __( '%s - date of this action ', 'secure-downloads' ), '<code>[current_date]</code>' );
$fields[] = sprintf( __( '%s - time of this action ', 'secure-downloads' ), '<code>[current_time]</code>' );
/*
//$fields[] = __('HTML tags is accepted.' , 'secure-downloads');
// $fields[] = '<hr/>';
// // show_additional_translation_shortcode_help
// $fields[] = '<strong>' . sprintf(__('Configuration in several languages' , 'secure-downloads') ) . '.</strong>';
// $fields[] = sprintf(__('%s - start new translation section, where %s - locale of translation' , 'secure-downloads'),'<code>[lang=LOCALE]</code>','<code>LOCALE</code>');
// $fields[] = sprintf(__('Example #1: %s - start French translation section' , 'secure-downloads'),'<code>[lang=fr_FR]</code>');
// $fields[] = sprintf(__('Example #2: "%s" - English and French translation of some message' , 'secure-downloads'),'<code>Thank you for your item.[lang=fr_FR]Je vous remercie de votre reservation.</code>');
*/
return $fields;
}
/** Check Email subject about Language sections
*
* @param string $subject
* @param string $email_id
* @return string
*/
function opsd_email_api_get_subject_before( $subject, $email_id ) {
$subject = apply_opsd_filter('opsd_check_for_active_language', $subject );
return $subject;
}
add_filter( 'opsd_email_api_get_subject_before', 'opsd_email_api_get_subject_before', 10, 2 ); // Hook fire in api-email.php
/** Check Email sections content about Language sections
*
* @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
* @param string $email_id - Email ID
* @param string $email_type - 'plain' | 'html'
*/
function opsd_email_api_get_content_before( $fields_values, $email_id , $email_type ) {
if ( isset( $fields_values['content'] ) ) {
$fields_values['content'] = apply_opsd_filter('opsd_check_for_active_language', $fields_values['content'] );
if ($email_type == 'html')
$fields_values['content'] = make_clickable( $fields_values['content'] );
}
if ( isset( $fields_values['header_content'] ) )
$fields_values['header_content'] = apply_opsd_filter('opsd_check_for_active_language', $fields_values['header_content'] );
if ( isset( $fields_values['footer_content'] ) )
$fields_values['footer_content'] = apply_opsd_filter('opsd_check_for_active_language', $fields_values['footer_content'] );
return $fields_values;
}
add_filter( 'opsd_email_api_get_content_before', 'opsd_email_api_get_content_before', 10, 3 ); // Hook fire in api-email.php
/** Modify email content, if needed. - In HTML mail content, make links clickable.
*
* @param array $email_content - content of Email
* @param string $email_id - Email ID
* @param string $email_type - 'plain' | 'html'
*/
function opsd_email_api_get_content_after( $email_content, $email_id , $email_type ) {
if ( ( $email_type == 'html' ) || ( $email_type == 'multipart' ) )
$email_content = make_clickable( $email_content );
return $email_content;
}
add_filter( 'opsd_email_api_get_content_after', 'opsd_email_api_get_content_after', 10, 3 ); // Hook fire in api-email.php
/** Check Email Headers - in New item Email (to admin) set Reply-To header to visitor email.
*
* @param string $headers
* @param string $email_id - Email ID
* @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
* @param array $replace_array - list of relpaced shortcodes
* @return string
*/
function opsd_email_api_get_headers_after( $mail_headers, $email_id , $fields_values , $replace_array, $additional_params = array() ) {
/*
// Default in api-emails.php:
// $mail_headers = 'From: ' . $this->get_from__name() . ' <' . $this->get_from__email_address() . '> ' . "\r\n" ;
// $mail_headers .= 'Content-Type: ' . $this->get_content_type() . "\r\n" ;
//
// $mail_headers = "From: $mail_sender\n";
// preg_match('/<(.*)>/', $mail_sender, $simple_email_matches );
// $reply_to_email = ( count( $simple_email_matches ) > 1 ) ? $simple_email_matches[1] : $mail_sender;
// $mail_headers .= 'Reply-To: ' . $reply_to_email . "\n";
// $mail_headers .= 'X-Sender: ' . $reply_to_email . "\n";
// $mail_headers .= 'Return-Path: ' . $reply_to_email . "\n";
*/
//debuge($mail_headers, $email_id , $fields_values , $replace_array);
if (
( $email_id == 'new_admin' ) // Only for email: "New item to Admin"
|| ( isset( $additional_params['reply'] ) )
) {
if ( isset( $replace_array['email'] ) ) { // Get email from the item form.
$reply_to_email = sanitize_email( $replace_array['email'] );
if ( ! empty( $reply_to_email ) )
$mail_headers .= 'Reply-To: ' . $reply_to_email . "\r\n" ;
// $mail_headers .= 'X-Sender: ' . $reply_to_email . "\r\n" ;
// $mail_headers .= 'Return-Path: ' . $reply_to_email . "\r\n" ;
}
}
return $mail_headers;
}
add_filter( 'opsd_email_api_get_headers_after', 'opsd_email_api_get_headers_after', 10, 5 ); // Hook fire in api-email.php
/** Check if we can send Email - block sending in live demos
*
* @param bool $is_send_email
* @param string $email_id
* @param array $fields_values - list of params to parse: 'content', 'header_content', 'footer_content' for different languges, etc ....
* @return bool
*/
function opsd_email_api_is_allow_send( $is_send_email, $email_id, $fields_values ) {
//debuge($fields_values);
if ( opsd_is_this_demo() )
$is_send_email = false;
return $is_send_email;
}
add_filter( 'opsd_email_api_is_allow_send', 'opsd_email_api_is_allow_send', 100, 3 ); // Hook fire in api-email.php
add_filter( 'opsd_email_api_is_allow_send_copy' , 'opsd_email_api_is_allow_send' , 100, 3);
/** Show warning about not sending emails, and reason about this.
*
* @param object $wp_error_object - WP Error object
* @param string $error_description - Description
*/
function opsd_email_sending_error( $wp_error_object, $error_description = '' ) {
if ( empty( $error_description ) ) {
// $error_description = __( 'Unknown exception', 'secure-downloads') . '.'; // Overwrite to show error, if no description ???
}
if ( ! empty( $error_description ) ) {
$error_description = '' . __('Error', 'secure-downloads') . '! ' . __('Email had not sent. Some error occuered.', 'secure-downloads') . ' ' . $error_description;
// Admin side
if ( function_exists( 'opsd_show_message' ) ) {
opsd_show_message ( $error_description , 15 , 'error');
}
// Front-end
?>
<script type="text/javascript">
if (typeof( opsd_show_message_under_element ) == 'function') {
opsd_show_message_under_element( '.opsd_form' , '<?php echo esc_js( $error_description ) ; ?>', '');
}
</script>
<?php
} else {
// Error that have no description. Its can be Empty Object like this: WP_Error Object( 'errors' => array(), 'error_data' => array() ), or NOT
// debuge( $wp_error_object );
}
}
add_action('opsd_email_sending_error', 'opsd_email_sending_error', 10, 2);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Files Loading
* @category Items
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 29.09.2015
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////
// L O A D F I L E S
////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/any/class-css-js.php' ); // Abstract. Loading CSS & JS files = Package: Any =
require_once( OPSD_PLUGIN_DIR . '/core/any/class-admin-settings-api.php' ); // Abstract. Settings API.
require_once( OPSD_PLUGIN_DIR . '/core/any/class-admin-page-structure.php' ); // Abstract. Page Structure in Admin Panel
require_once( OPSD_PLUGIN_DIR . '/core/any/class-admin-menu.php' ); // CLASS. Menus of plugin
require_once( OPSD_PLUGIN_DIR . '/core/any/admin-bs-ui.php' ); // Functions. Toolbar BS UI Elements
if( is_admin() ) {
require_once OPSD_PLUGIN_DIR . '/core/any/opsd-class-dismiss.php'; // Class - Dismiss
require_once OPSD_PLUGIN_DIR . '/core/any/opsd-class-notices.php'; // Class - Notices
}
// Functions ////////////////////////////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/opsd-debug.php' ); // Debug = Package: OPSD =
require_once( OPSD_PLUGIN_DIR . '/core/opsd-core.php' ); // Core
require_once( OPSD_PLUGIN_DIR . '/core/opsd-translation.php' ); // Translations
require_once( OPSD_PLUGIN_DIR . '/core/opsd-functions.php' ); // Functions
require_once( OPSD_PLUGIN_DIR . '/core/opsd-products.php' ); // Products Functions
require_once( OPSD_PLUGIN_DIR . '/core/opsd-download.php' ); // Download Functions
require_once( OPSD_PLUGIN_DIR . '/core/opsd-upload.php' ); // Upload Functions
require_once( OPSD_PLUGIN_DIR . '/core/opsd-emails.php' ); // Emails
// JS & CSS ////////////////////////////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/opsd-css.php' ); // Load CSS
require_once( OPSD_PLUGIN_DIR . '/core/opsd-js.php' ); // Load JavaScript and define JS Varibales
// Admin UI ////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/admin/opsd-toolbars.php' ); // Toolbar - BS UI Elements
require_once( OPSD_PLUGIN_DIR . '/core/admin/opsd-dashboard.php' ); // Dashboard Widget
// Admin Pages ////////////////////////////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-send.php' ); // Master page
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-files-add.php' ); // Add New page
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-files-sortable.php' ); // Sortable List page
//require_once( OPSD_PLUGIN_DIR . '/core/admin/exmpl-opsd-class-listing.php' ); // CLASS. item Listing Table // 4.F.U.T.U.R.E
//require_once( OPSD_PLUGIN_DIR . '/core/admin/exmpl-page-with-toolbars-listing.php' ); // Template of page with toolbars // 4.F.U.T.U.R.E
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-settings.php' ); // Settings page
require_once( OPSD_PLUGIN_DIR . '/core/admin/api-settings.php' ); // Settings API
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-email-link-user.php' ); // Email - send email with download link to user
require_once( OPSD_PLUGIN_DIR . '/core/admin/page-email-download_notification.php' ); // Email - send email about downloads happend
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
require_once( OPSD_PLUGIN_DIR . '/core/any/activation.php' );
require_once( OPSD_PLUGIN_DIR . '/core/opsd-activation.php' );
make_opsd_action( 'opsd_loaded_php_files' );

View File

@@ -0,0 +1,291 @@
<?php /**
* @version 1.0
* @package Secure Downloads
* @category JavaScript files and varibales
* @author wpdevelop
*
* @web-site https://oplugins.com/
* @email info@oplugins.com
*
* @modified 19.10.2015
*/
class OPSD_JS extends OPSD_JS_CSS {
public function define() {
$this->setType('js');
/*
$this->add( array(
'handle' => 'opsd-datepick',
'src' => opsd_plugin_url( '/js/datepick/jquery.datepick.js'),
'deps' => array( 'opsd-global-vars' ),
'version' => '1.1',
'where_to_load' => array( 'admin', 'client' ), //Usage: array( 'admin', 'client' )
'condition' => false
) );
*/
}
/** Enqueue Files and Varibales.
* Useful in case, if we use get_options and current user functions...
*
* @param type $where_to_load
*/
public function enqueue( $where_to_load ) {
opsd_js_load_vars( $where_to_load );
// Define JavaScript varibales in all other files
do_action( 'opsd_define_js_vars', $where_to_load );
opsd_js_load_libs( $where_to_load );
opsd_js_load_files( $where_to_load );
if ( opsd_is_new_opsd_page() )
$where_to_load = 'both';
// Load JavaScript files in all other versions
do_action( 'opsd_enqueue_js_files', $where_to_load );
}
/** Deregister some conflict scripts from other plugins.
*
* @param type $where_to_load
*/
public function remove_conflicts( $where_to_load ) {
if ( opsd_is_master_page() ) {
if (function_exists('wp_dequeue_script')) {
//wp_dequeue_script( 'jquery.cookie' );
//wp_dequeue_script( 'jquery-interdependencies' );
//wp_dequeue_script( 'chosen' ); //FixIn: 1.2.1
wp_dequeue_script( 'cs-framework' );
wp_dequeue_script( 'cgmp-jquery-tools-tooltip' ); // Remove this script jquery.tools.tooltip.min.js, which is load by the "Comprehensive Google Map Plugin"
}
}
}
}
/** Define JavaScript Varibales */
function opsd_js_load_vars( $where_to_load ) {
////////////////////////////////////////////////////////////////////////////
// JavaScripts Variables
////////////////////////////////////////////////////////////////////////////
if ( $where_to_load == 'admin' ) { //FixIn: 1.1.2
wp_enqueue_script( 'opsd-global-vars', opsd_plugin_url( '/js/opsd_vars.js' ), array( 'jquery' ), '1.1' ); // Blank JS File
wp_localize_script( 'opsd-global-vars'
, 'opsd_global1', array(
'opsd_ajaxurl' => admin_url( 'admin-ajax.php' )
, 'opsd_plugin_url' => plugins_url( '' , OPSD_FILE )
, 'opsd_today' => '[' . intval(date_i18n('Y')) //FixIn:6.1
.','. intval(date_i18n('m'))
.','. intval(date_i18n('d'))
.','. intval(date_i18n('H'))
.','. intval(date_i18n('i'))
.']'
, 'opsd_plugin_filename' => OPSD_PLUGIN_FILENAME
, 'message_verif_requred' => esc_js(__('This field is required' , 'secure-downloads'))
, 'message_verif_requred_for_check_box' => esc_js(__('This checkbox must be checked' , 'secure-downloads'))
, 'message_verif_requred_for_radio_box' => esc_js(__('At least one option must be selected' , 'secure-downloads'))
, 'message_verif_emeil' => esc_js(__('Incorrect email field' , 'secure-downloads'))
, 'message_verif_same_emeil' => esc_js(__('Your emails do not match' , 'secure-downloads')) // Email Addresses Do Not Match
, 'opsd_active_locale' => opsd_get_locale()
, 'opsd_message_processing' => esc_js( __('Processing' , 'secure-downloads') )
, 'opsd_message_deleting' => esc_js( __('Deleting' , 'secure-downloads') )
, 'opsd_message_updating' => esc_js( __('Updating' , 'secure-downloads') )
, 'opsd_message_saving' => esc_js( __('Saving' , 'secure-downloads') )
));
}
}
/** Default JavaScripts Libraries */
function opsd_js_load_libs( $where_to_load ) {
// jQuery
wp_enqueue_script( 'jquery' );
//FixIn: 1.1.5.1
// Default Admin Libs
if ( ( $where_to_load == 'admin' )
// || ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) )
) {
wp_enqueue_media();
wp_enqueue_script('thickbox');
// Load thickbox CSS
wp_enqueue_style('thickbox');
wp_enqueue_style( 'wp-color-picker' ); // Color Picker
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_script( 'jquery-ui-sortable' ); // UI Sortable
// if ( opsd_is_master_page() )
// wp_enqueue_script( 'jquery-ui-dialog' ); // UI Dialog - for payment request dialog
}
}
/** Load JavaScript Files */
function opsd_js_load_files( $where_to_load ) {
// Bootstrap
if ( ( ( is_admin() ) && ( get_opsd_option( 'opsd_is_not_load_bs_script_in_admin' ) !== 'On') )
// || ( ( ! is_admin() ) && ( get_opsd_option( 'opsd_is_not_load_bs_script_in_client' ) !== 'On' ) )
) {
wp_enqueue_script( 'wpdevelop-bootstrap', opsd_plugin_url( '/assets/libs/bootstrap/js/bootstrap.js' ), array( 'opsd-global-vars' ), '3.3.5.1');
}
// Datepicker
// wp_enqueue_script( 'opsd-datepick', opsd_plugin_url( '/js/datepick/jquery.datepick.js'), array( 'opsd-global-vars' ), '1.1');
// Localization
// $calendar_localization_url = opsd_get_calendar_localization_url();
// if ( ! empty( $calendar_localization_url ) )
// wp_enqueue_script( 'opsd-datepick-localize', $calendar_localization_url, array( 'opsd-datepick' ), '1.1');
//opsd_load_calendar_localization_file();
if ( ( $where_to_load == 'client' ) || ( opsd_is_new_opsd_page() ) ) {
// Client
// wp_enqueue_script( 'opsd-main-client', opsd_plugin_url( '/js/client.js'), array( 'opsd-datepick' ), '1.1');
}
if ( $where_to_load == 'admin' ) {
// Admin
wp_enqueue_script( 'opsd-admin-main', opsd_plugin_url( '/js/admin.js'), array( 'opsd-global-vars' ), '1.1');
wp_enqueue_script( 'opsd-admin-support', opsd_plugin_url( '/core/any/js/admin-support.js'), array( 'opsd-global-vars' ), '1.1');
// Chosen Library
// wp_enqueue_script( 'opsd-chosen', opsd_plugin_url( '/assets/libs/chosen/chosen.jquery.min.js'), array( 'opsd-global-vars' ), '1.1' ); //FixIn: 1.1.2.5
}
}
////////////////////////////////////////////////////////////////////////////////
// Support JavaScript functions
////////////////////////////////////////////////////////////////////////////////
/** Load Datepicker Localization JS File */
/*
function opsd_load_calendar_localization_file() {
// Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR';
$locale = opsd_get_locale();
if ( ! empty( $locale ) ) {
$locale_lang = substr( $locale, 0, 2 );
$locale_country = substr( $locale, 3 );
if ( ( $locale_lang !== 'en') && ( opsd_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) {
wp_enqueue_script( 'opsd-datepick-localize', opsd_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' ), array( 'opsd-datepick' ), '1.1');
} else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions
&& ( opsd_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) )
) {
wp_enqueue_script( 'opsd-datepick-localize', opsd_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ), array( 'opsd-datepick' ), '1.1');
}
}
}*/
/** Get URL Datepicker Localization JS File
*
* @return string - URL to calendar skin
*/
/*
function opsd_get_calendar_localization_url() {
// Datepicker Localization - translation for calendar. Example: $locale = 'fr_FR';
$locale = opsd_get_locale();
$calendar_localization_url = false;
if ( ! empty( $locale ) ) {
$locale_lang = substr( $locale, 0, 2 );
$locale_country = substr( $locale, 3 );
if ( ( $locale_lang !== 'en') && ( opsd_is_file_exist( '/js/datepick/jquery.datepick-' . $locale_lang . '.js' ) ) ) {
$calendar_localization_url = opsd_plugin_url( '/js/datepick/jquery.datepick-'. $locale_lang . '.js' );
} else if ( ( ! in_array( $locale, array( 'en_US', 'en_CA', 'en_GB', 'en_AU' ) ) ) // English Exceptions
&& ( opsd_is_file_exist( '/js/datepick/jquery.datepick-'. $locale_country . '.js' ) )
) {
$calendar_localization_url = opsd_plugin_url( '/js/datepick/jquery.datepick-'. $locale_country . '.js' );
}
}
return $calendar_localization_url;
}
*/
/** Get Registred jQuery version
*
* @global type $wp_scripts
* @return string - jQuery version
*/
function opsd_get_registered_jquery_version() {
global $wp_scripts;
$version = false;
if ( is_a( $wp_scripts, 'WP_Scripts' ) )
if (isset( $wp_scripts->registered['jquery'] ))
$version = $wp_scripts->registered['jquery']->ver;
return $version;
}
/** Check if we activated loading of JS/CSS only on specific pages and then load or no it
*
* @param boolean $is_load_scripts - Default: true
* @return boolean - true | false
*/
function opsd_is_load_css_js_on_client_page( $is_load_scripts ) {
return true;
if ( ! is_admin() ) { // Check on Client side only
$opsd_is_load_js_css_on_specific_pages = get_opsd_option( 'opsd_is_load_js_css_on_specific_pages' );
if ( $opsd_is_load_js_css_on_specific_pages == 'On' ) {
$opsd_pages_for_load_js_css = get_opsd_option( 'opsd_pages_for_load_js_css' );
$opsd_pages_for_load_js_css = preg_split('/[\r\n]+/', $opsd_pages_for_load_js_css, -1, PREG_SPLIT_NO_EMPTY);
$request_uri = $_SERVER['REQUEST_URI']; // FixIn:5.4.1
if ( strpos( $request_uri, 'opsd_hash=') !== false ) {
$request_uri = parse_url($request_uri);
if ( ( ! empty($request_uri ) ) && ( isset($request_uri['path'] ) ) ){
$request_uri = $request_uri['path'];
} else {
$request_uri = $_SERVER['REQUEST_URI'];
}
}
if ( ( ! empty($opsd_pages_for_load_js_css ) ) && ( ! in_array( $request_uri, $opsd_pages_for_load_js_css ) ) )
return false;
}
}
return true;
}
add_filter( 'opsd_is_load_script_on_this_page', 'opsd_is_load_css_js_on_client_page' );

View File

@@ -0,0 +1,307 @@
<?php
/**
* @version 1.0
* @package Products
* @subpackage Support for Download Functions
* @category Products
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2017-03-01
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Products for downloading */
class OPSD_Products {
protected $products = array();
public static $settings = array( 'csv_separator' => ',' ); // unlike a const, static property values can be changed
function __construct( $csv = '' ) {
$opsd_csv_separator = get_opsd_option( 'opsd_csv_separator' );
if ( ! empty( $opsd_csv_separator ) )
self::$settings[ 'csv_separator' ] = $opsd_csv_separator;
if ( ! empty( $csv ) ) {
$this->define_products_from_csv( $csv );
}
}
/** Parse CSV in specific format and Load Products.
*
* @param string $csv
*/
public function define_products_from_csv( $csv = '' ) {
if ( empty( $csv ) ) {
$csv = get_opsd_option('opsd_products_csv' );
}
// ID | Title | Version Number | Desciption | Path
//
// $this->products = array(); //Do we need to reset exist products list
$defaults = array( 'id' => ''
, 'order' => '0'
, 'ip' => '0.0.0.0' // '0.0.0.0' or '0' - Its means any IP
, 'expire' => '+1 day' // for usage in strtotime function
);
if ( ! empty( $csv ) ) {
$csv = str_replace( array("\r\n", "\r"), "\n", $csv );
$csv_lines = explode( "\n", $csv );
foreach ( $csv_lines as $csv_line ) {
//0,Prod,Description,XXXXXXXXXX/fold/product.zip,0,1440
$product_from_csv = explode( self::$settings['csv_separator'], $csv_line );
if ( count($product_from_csv) > 4 ) {
$product_arr = array();
$i = 0;
// 137^Title OPSD^Version Number OPSD^Description^http://new/wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04/1-1.txt
$product_arr[ 'id' ] = trim( $product_from_csv[ $i ++ ] );
$product_arr[ 'title' ] = trim( $product_from_csv[ $i ++ ] );
$product_arr[ 'version_num' ] = trim( $product_from_csv[ $i ++ ] );
$product_arr[ 'description' ] = trim( $product_from_csv[ $i ++ ] );
$product_arr[ 'path' ] = trim( str_replace( site_url(), '', $product_from_csv[ $i ++ ] ) ); // Get local relative path
$this->products[] = wp_parse_args( $product_arr, $defaults ); // Add Product
} else if ( count( $product_from_csv ) == 1 ){
// Get section title - usually its contain only from TEXT row without COLUMN SEPARTORs
$this->products[] = array( 'id' => floatval( microtime( false ) ) + wp_rand( 100 ), 'title' => $product_from_csv[0] ); //FixIn: 1.1.2.3
}
}
}
//debuge($this->products);
}
/** Count Real Products with Path to files
*
* @return int
*/
function get_products_count() {
$cnt = 0;
foreach ( $this->products as $prod ) {
if ( ! empty( $prod[ 'path' ] ) )
$cnt ++;
}
return $cnt;
}
/** Save products from products array
*
* @param array $new_products_arr
*/
public function save_products( $new_products_arr ) {
if ( is_array( $new_products_arr )) {
$csv_line = array();
foreach ( $new_products_arr as $product_arr ) {
$csv_arr = array();
if ( isset( $product_arr['id'] ) ) {
$csv_arr[] = str_replace( self::$settings['csv_separator'], '_', $product_arr['id'] ); // Fix issue of not have separator in contne of field
}
if ( isset( $product_arr['title'] ) ) {
$csv_arr[] = str_replace( self::$settings['csv_separator'], '_', $product_arr['title'] ); // Fix issue of not have separator in contne of field
}
if ( isset( $product_arr['version_num'] ) ) {
$csv_arr[] = str_replace( self::$settings['csv_separator'], '_', $product_arr['version_num'] ); // Fix issue of not have separator in contne of field
}
if ( isset( $product_arr['description'] ) ) {
$csv_arr[] = str_replace( self::$settings['csv_separator'], '_', $product_arr['description'] ); // Fix issue of not have separator in contne of field
}
if ( isset( $product_arr['path'] ) ) {
$csv_arr[] = str_replace( self::$settings['csv_separator'], '', $product_arr['path'] ); // Fix issue of not have separator in contne of field
}
$csv_line[] = implode( self::$settings['csv_separator'], $csv_arr );
}
$csv_line = implode( "\n", $csv_line );
update_opsd_option( 'opsd_products_csv', $csv_line );
return $csv_line;
}
return false;
}
public function get_products() {
return $this->products;
}
/** Get product by ID
*
* @param type $id
* @return array | boolean
*/
public function get_product( $id ) {
foreach ( $this->products as $product ) {
if ( $product['id'] == $id )
return $product;
}
return false;
}
}
/** Get Array of properties for specific product
*
* @param int $product_id - id of resource
* @return array (
[id] => 2
[order] => 0
[ip] => 0.0.0.0
[ipl] => 0
[expire] => +1440 seconds
[title] => Pro (1 site usage)
[size] => 3.45
[path] => XXXXXXXXXX/pro/pro.zip
*/
function opsd_get_product( $product_id ) {
$products_obj = new OPSD_Products( get_opsd_option('opsd_products_csv' ) );
return $products_obj->get_product( $product_id );
}
/** Get replace shortcode for different products.
*
* @param array $product_id_arr - product array
* @param array $opt - optional array with parameters, which redefined default product values array(
'expire' => '+1 day'
'ip' => '149.10.0.1'
)
* @return array array (
[products_list] => Array( .... )
[product_id] - ID of product
[product_title] - title of product
[product_description] - description of product
[product_link] - secure URL for product download
[product_filename] - filename of the product
[product_size] - the download size in a friendly format such as 500 KB or 3.45 MB
[product_expire_after] - expiry time in friendly format (e.g. 24 hours or 2 days etc)
[product_expire_date] - exact expiry date and time (e.g. 2017-03-21 18:30)
[product_summary] - complete product details including title, size, link etc
---
[siteurl] - inserting your site URL
[remote_ip] - inserting IP address of the user who made this action
[user_agent] - inserting contents of the User-Agent: header from the current request, if there is one
[request_url] - inserting address of the page (if any), where visitor make this action
[current_date] - inserting date of this action
[current_time] - inserting time of this action
)
*/
function opsd_get_product_replace_shortcodes( $product_id_arr = array(), $opt = array() ) {
$replace = array( 'products_list' => array() );
// Init and load all products
$products_obj = new OPSD_Products( get_opsd_option('opsd_products_csv' ) );
$product_id_arr = (array) $product_id_arr;
foreach ( $product_id_arr as $product_id ) {
$products_replace = array();
$product_arr = $products_obj->get_product( $product_id );
if ( ( empty( $product_arr[ 'path' ] ) )
|| ( empty( $product_arr[ 'id' ] ) )
)
continue;
$products_replace['product_id'] = $product_arr['id']; // 1
$products_replace['product_title'] = apply_opsd_filter( 'opsd_check_for_active_language', $product_arr['title'] ); // Product Name
$products_replace['product_version'] = apply_opsd_filter( 'opsd_check_for_active_language', $product_arr['version_num'] ); // May be update num
$products_replace['product_description']= apply_opsd_filter( 'opsd_check_for_active_language', $product_arr['description'] ); // Tra ta ta ...
if ( ! empty( $opt[ 'order' ] ) ) {
$products_replace['order'] = $opt[ 'order' ];
if ( strpos( $opt[ 'order' ], '@' ) !== false ) {
$products_replace['link_sent_to'] = $opt[ 'order' ];
}
}
$products_replace['product_link'] = opsd_get_secret_link( $product_arr, $opt ); // http://server.com/?prefix=922015&product=MSwxNDg5OTI3Njg4LDAsMC4wLjAuMCwwLGFmYTFmMW/product.zip
$products_replace['product_link'] = htmlspecialchars_decode(
// '<a href="' .
esc_url( $products_replace['product_link'] )
// . '">' . __('here', 'secure-downloads') . '</a>'
);
// Get Redable Size of file
$real_link = rtrim( get_site_url() , '/' ) . '/' . ltrim( $product_arr[ 'path' ], '/\\' );
$real_size = OPSD_Download::get_file_size( OPSD_Download::get_local_path_from_real_link( $real_link ) );
$redable_size = OPSD_Download::readable_format_file_size( $real_size );
$products_replace['product_size'] = $redable_size; // 2.93 MB
$products_replace['product_filename'] = OPSD_Download::get_file_name_from_path( $real_link ); // product.zip
// Do we ovveride expire CSV parameter from request FORM
if ( ! empty( $opt['expire'] ) ) $product_arr['expire'] = $opt['expire'];
if ( opsd_is_valid_timestamp( $product_arr['expire'] ) ) {
$expire_time_stamp = $product_arr['expire'];
} else {
$expire_time_stamp = strtotime( $product_arr['expire'] , current_time( 'timestamp' ) );
}
$readable_expire = OPSD_Download::readable_format_seconds_to_words( $expire_time_stamp - current_time( 'timestamp' ) );
// 2 days
$products_replace['product_expire_after'] = $readable_expire;
// 2017-03-19 14:48:08
$products_replace['product_expire_date'] = date_i18n( get_opsd_option( 'opsd_date_format' ) . ' ' . get_opsd_option( 'opsd_time_format' )
, $expire_time_stamp );
$products_replace['product_summary'] = '<strong>' . $products_replace['product_title'] . '</strong> '
. '<a href="' . $products_replace['product_link'] . '" target="_blank">'
. $products_replace['product_filename']
. '</a>'
. ' ('. $products_replace['product_size'] .')'
. ' ~ ' . __( 'expire in', 'secure-downloads' ) . ' ' . $products_replace['product_expire_after'];
$replace['products_list'][]= $products_replace;
}
$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' ] = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : ''; // Contents of the User-Agent: header from the current request, if there is one.
$replace[ 'request_url' ] = (isset($_SERVER['HTTP_REFERER'])) ? $_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' ) );
// Get values for 1-st product
if ( ! empty( $replace['products_list'] ) ){
foreach ( $replace['products_list'][0] as $product_key => $product_value ) {
$replace[ $product_key ] = $product_value;
}
}
//debuge('$replace',$replace);
return $replace;
}

View File

@@ -0,0 +1,244 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Translations Functions
* @category Functions
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 29.09.2015
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
////////////////////////////////////////////////////////////////////////////////
// Transaltions ////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// New in WP 6.2 - firstly loaded transaltion from wp-content/languges and then chek only
// use the override_load_textdomain filter to load your text domains manually.
// apply_filters( 'override_load_textdomain', bool $override, string $domain, string $mofile )
/** Check text for active language section
*
* @param string $content_orig
* @return string
* Usage:
* $text = apply_opsd_filter('opsd_check_for_active_language', $text );
*/
function opsd_check_for_active_language($content_orig){
$content = $content_orig;
$languages = array();
$content_ex = explode('[lang',$content);
foreach ($content_ex as $value) {
if (substr($value,0,1) == '=') {
$pos_s = strpos($value,'=');
$pos_f = strpos($value,']');
$key = trim( substr($value, ($pos_s+1), ($pos_f-$pos_s-1) ) );
$value_l = trim( substr($value, $pos_f+1 ) );
$languages[$key] = $value_l;
} else
$languages['default'] = $value;
}
$locale = opsd_get_locale();
// $locale = 'fr_FR';
if ( isset( $languages[$locale] ) ) $return_text = $languages[ $locale ];
else $return_text = $languages[ 'default' ];
$return_text = opsd_check_qtranslate( $return_text, $locale );
$return_text = opsd_check_wpml_tags( $return_text, $locale ); //FixIn: 5.4.5.8
return $return_text;
}
/** Register and Translate everything in [wpml]Some Text to translate[/wpml] tags.
*
* @param string $text
* @param string $locale
* @return string
*/
function opsd_check_wpml_tags( $text, $locale='' ) { //FixIn: 5.4.5.8
if ( $locale == '' ) {
$locale = opsd_get_locale();
}
if ( strlen( $locale ) > 2 ) {
$locale = substr($locale, 0, 2 );
}
$is_tranlsation_exist_s = strpos( $text, '[wpml]' );
$is_tranlsation_exist_f = strpos( $text, '[/wpml]' );
if ( ( $is_tranlsation_exist_s !== false ) && ( $is_tranlsation_exist_f !== false ) ) {
$shortcode = 'wpml';
// Find anything between [wpml] and [/wpml] shortcodes. Magic here: [\s\S]*? - fit to any text
preg_match_all( '/\[' . $shortcode . '\]([\s\S]*?)\[\/' . $shortcode . '\]/i', $text, $wpml_translations, PREG_SET_ORDER );
//debuge( $wpml_translations );
foreach ( $wpml_translations as $translation ) {
$text_to_replace = $translation[0];
$translation_to_check = $translation[1];
if ( function_exists ( 'icl_register_string' ) ){
if ( false ) { // Depricated functions
// Help: https://wpml.org/documentation/support/translation-for-texts-by-other-plugins-and-themes/
icl_register_string('Item Calendar', 'opsd-' . tag_escape( $translation_to_check ) , $translation_to_check );
//TODO: Need to execurte this after deactivation of plugin or after updating of some option...
//icl_unregister_string ( 'Item Calendar', 'opsd-' . tag_escape( $translation_to_check ) );
if ( function_exists ( 'icl_translate' ) ){
$translation_to_check = icl_translate ( 'Item Calendar', 'opsd-' . tag_escape( $translation_to_check ) , $translation_to_check );
}
} else { // WPML Version: 3.2
// Help info: do_action( 'wpml_register_single_string', string $context, string $name, string $value )
// https://wpml.org/wpml-hook/wpml_register_string_for_translation/
do_action( 'wpml_register_single_string', 'Item Calendar', 'opsd-' . tag_escape( $translation_to_check ) , $translation_to_check );
// Help info: apply_filters( 'wpml_translate_single_string', string $original_value, string $context, string $name, string $$language_code )
// https://wpml.org/wpml-hook/wpml_translate_single_string/
//$translation_to_check = apply_filters( 'wpml_translate_single_string', $translation_to_check, 'Item Calendar', 'opsd-' . tag_escape( $translation_to_check ) );
$language_code = $locale;
$translation_to_check = apply_filters( 'wpml_translate_single_string', $translation_to_check, 'Item Calendar', 'opsd-' . tag_escape( $translation_to_check ), $language_code );
}
}
$text = str_replace( $text_to_replace, $translation_to_check, $text );
}
}
return $text;
}
function opsd_check_qtranslate( $text, $locale='' ){
if ($locale == '') {
$locale = opsd_get_locale();
}
if (strlen($locale)>2) {
$locale = substr($locale, 0 ,2);
}
$is_tranlsation_exist = strpos($text, '<!--:'.$locale.'-->');
if ($is_tranlsation_exist !== false) {
$tranlsation_end = strpos($text, '<!--:-->', $is_tranlsation_exist);
$text = substr($text, $is_tranlsation_exist , ($tranlsation_end - $is_tranlsation_exist ) );
}
return $text;
}
function opsd_load_translation(){
//$locale = 'fr_FR'; opsd_load_locale( $locale );
if ( ! opsd_load_locale() ) {
opsd_load_locale('en_US');
}
$locale = opsd_get_locale();
}
/** Overload loading of plugin transaltion files from "wp-content/plugins/languages" -> "wp-content/plugins/plugin_name/languages"
*
* W:\home\beta\www/wp-content/languages/plugins/secure-downloads-it_IT.mo -> W:\home\beta\www\wp-content\plugins\secure-downloads/languages/secure-downloads-it_IT.mo
*
* @param string $mofile
* @param type $domain
* @return string
*/
function opsd_load_custom_plugin_translation_file( $mofile, $domain ) {
if ( $domain == 'secure-downloads' ) {
$mofile = OPSD_PLUGIN_DIR . '/languages/' . basename( $mofile );
}
return $mofile;
}
add_filter( 'load_textdomain_mofile', 'opsd_load_custom_plugin_translation_file' , 10, 2 );
function opsd_load_locale( $locale = '' ) {
if ( empty( $locale ) )
$locale = opsd_get_locale();
if ( ! empty( $locale ) ) {
$domain = 'secure-downloads';
$mofile = OPSD_PLUGIN_DIR . '/languages/' . $domain . '-' . $locale . '.mo';
if ( file_exists( $mofile ) ) {
$plugin_rel_path = OPSD_PLUGIN_DIRNAME . '/languages' ;
return load_plugin_textdomain( $domain, false, $plugin_rel_path ) ;
}
}
return false;
}
function opsd_get_locale() {
if ( defined( 'OPSD_RELOAD' ) )
return OPSD_RELOAD;
else
define( 'OPSD_RELOAD', get_locale() );
return get_locale();
}
function opsd_recheck_plugin_locale( $locale, $plugin_domain = '' ) { //FixIn: 1.1.2.2
if ( $plugin_domain == 'item' )
if ( defined('OPSD_RELOAD') )
return OPSD_RELOAD;
return $locale;
}
add_filter( 'plugin_locale', 'opsd_recheck_plugin_locale', 100, 2 ); // When load_plugin_text_domain is work, its get def locale and not that, we send to it so need to reupdate it
/** Get help rows about configuration in_several languges
*
* @return array - each item of array is text row for showing.
*/
function opsd_get_help_rows_about_config_in_several_languges() {
$field_options = array();
$field_options[] = '<strong>' . __('Configuration in several languages' , 'secure-downloads') . '</strong>';
$field_options[] = sprintf(__('%s - start new translation section, where %s - locale of translation' , 'secure-downloads'),'<code>[lang=LOCALE]</code>','<code>LOCALE</code>');
$field_options[] = sprintf(__('Example #1: %s - start French translation section' , 'secure-downloads'),'<code>[lang=fr_FR]</code>');
$field_options[] = sprintf(__('Example #2: "%s" - English and French translation of some message' , 'secure-downloads'),'<code>Thank you for your item.[lang=fr_FR]Je vous remercie de votre reservation.</code>');
return $field_options;
}

View File

@@ -0,0 +1,704 @@
<?php
/**
* @version 1.0
* @package File Upload
* @subpackage Support Upload Functions
* @category Functions
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2017-04-14
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/** Code usage in other places for Upload, Selection and Insertion of file URL
*
<div>
<input type="text" value="" wrap="off" placeholder="..." class="opsd_file_urls" name="opsd_file_urls" />
<a href="javascript:void(0)" class="button opsd_btn_upload"
data-modal_title="<?php echo esc_attr( __( 'Choose file', 'secure-downloads' ) ); ?>"
data-btn_title="<?php echo esc_attr( __( 'Insert file URL', 'secure-downloads' ) ); ?>"
><?php _e( 'Upload File', 'secure-downloads' ); ?></a>
</div>
<?php
$opsd_upload = opsd_upload(); // Get OPSD_Upload obj instance
$opsd_upload->set_upload_button( '.opsd_btn_upload' );
$opsd_upload->set_element_insert_url( '.opsd_file_urls' );
?>
*
*/
// General Init Class
final class OPSD_Upload {
public $settings = array(
'upload_button' => ''
, 'element_insert_url' => ''
, 'wp_media_uploader_params' => array( 'key' => 'opsd_type', 'value' => 'opsd_upload' ) // Required for setting OUR Dir for uploading and set it PROTECTED
);
// Define only one instance of this class
static private $instance = NULL;
public static function init() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof OPSD_Upload ) ) {
self::$instance = new OPSD_Upload;
add_filter( 'upload_dir', array( self::$instance, 'filter_upload_dir' ) );
add_action( 'admin_footer', array( self::$instance, 'js' ), 50 ); // Load JavaScript Code at the footer of the Admin Panel page. Executed in ALL Admin Menu Pages
//TODO: remove this
// add_filter( 'posts_where', array( self::$instance, 'opsd_filter_posts_where' ) );
// add_action('pre_get_posts', array( self::$instance, 'opsd_pre_get_posts' ) );
self::$instance->protect_upload_dir();
}
return self::$instance;
}
/** Get Name of protected DIR name, like opsd_XXXXX
*
* @return string
*/
public function get_protected_dir_name() {
$get_protected_dir_name = get_opsd_option( 'opsd_protected_directory_name_level1' );
if ( empty( $get_protected_dir_name ) ) {
$get_protected_dir_name = 'opsd_' . wp_generate_password( 20, false, false );
update_opsd_option( 'opsd_protected_directory_name_level1', $get_protected_dir_name );
}
$get_protected_dir_name = untrailingslashit($get_protected_dir_name);
return $get_protected_dir_name;
}
/** Get all settings or specific setting option
*
* @param string $key
* @return mixed
*/
public function get_settings( $key = '' ) {
if ( '' === $key )
return $this->settings;
if ( isset( $this->settings[ $key ] ) )
return $this->settings[ $key ];
else
return false;
}
//TODO: remove this
/*
function opsd_pre_get_posts( $query ) {
debuge_log( $_POST );
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
$discount = $query->get( 'discount' );
if ( ! empty( $discount ) ) {
// unset ref var from $wp_query
$query->set( 'discount', null );
global $wp;
// unset ref var from $wp
unset( $wp->query_vars[ 'discount' ] );
// if in home (because $wp->query_vars is empty) and 'show_on_front' is page
if ( empty( $wp->query_vars ) && get_option( 'show_on_front' ) === 'page' ) {
// reset and re-parse query vars
$wp->query_vars['page_id'] = get_option( 'page_on_front' );
$query->parse_query( $wp->query_vars );
}
}
}
*/
//TODO: remove this
/**
* @param string $where Where clause
* @return string $where Modified where clause
*/
/*
function opsd_filter_posts_where( $where = '' ) {
debuge_log( $_POST );
return $where;
//debuge( maybe_unserialize( 'a:3:{s:6:"action";s:17:"query-attachments";s:7:"post_id";s:1:"0";s:5:"query";a:4:{s:7:"orderby";s:4:"date";s:5:"order";s:4:"DESC";s:14:"posts_per_page";s:2:"40";s:5:"paged";s:1:"1";}}' ));
$media_uploader_params = $this->get_settings( 'wp_media_uploader_params' );
if ( ( isset( $_POST['query'] ) )
&& ( isset( $_POST['query'][ $media_uploader_params[ 'key' ] ] ) )
&& ( $media_uploader_params[ 'value' ] === $_POST['query'][ $media_uploader_params[ 'key' ] ] )
) {
global $wpdb;
$where .= " AND guid LIKE '%".$wpdb->esc_like( untrailingslashit( get_opsd_option( 'opsd_protected_directory_name_level1' ) ) )."%'";
}
return $where;
}
*/
/** Filters the uploads directory array,
* after CLICKING on our Upload Button and USE our wp.media thanks to 'wp_media_uploader_params'
*
* @param array $uploads Array of upload directory data:
array (
[path] => Z:\home\new\www/wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04
[url] => http://new/wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04
[subdir] => /opsd_lSJacOT1yVLFnrkqt2xR/2017/04
[basedir] => Z:\home\new\www/wp-content/uploads
[baseurl] => http://new/wp-content/uploads
[error] =>
)
*$uploads = apply_filters( 'upload_dir', $cache[ $key ] );
*
* @param type $param
*/
public function filter_upload_dir( $param ) {
//TODO: here we can create own TAGs and Versioning directory structure in some way.
$media_uploader_params = $this->get_settings( 'wp_media_uploader_params' );
if ( isset( $_POST[ $media_uploader_params[ 'key' ] ] ) && $media_uploader_params[ 'value' ] === $_POST[ $media_uploader_params[ 'key' ] ] ) {
$protected_dir_name = $this->get_protected_dir_name();
if ( empty( $param['subdir'] ) ) {
$param['path'] = $param['path'] . '/' . $protected_dir_name;
$param['url'] = $param['url'] . '/' . $protected_dir_name;
$param['subdir'] = '/' . $protected_dir_name;
} else {
$new_subdir = '/' . $protected_dir_name . $param['subdir'];
$param['path'] = str_replace( $param['subdir'], $new_subdir, $param['path'] );
$param['url'] = str_replace( $param['subdir'], $new_subdir, $param['url'] );
$param['subdir'] = str_replace( $param['subdir'], $new_subdir, $param['subdir'] );
}
}
return $param;
}
/** Get path to protected dir.
*
* @return type
*/
public function get_protected_dir() {
// Protected secret name LEVEL 1
$dir_level1 = $this->get_protected_dir_name();
// Install files and folders for uploading files and prevent hotlinking
$upload_dir = wp_upload_dir();
return $upload_dir['basedir'] . '/' . $dir_level1;
}
/** Check and Protect upload folder each time
*
* May be we need to have 2 folders, like /opsd_xxxxx/XXXXXXXXXXXXX
* for prevent of dir listing at previous stage /opsd_xxxxx with .htaccess file
*
* Typical Directory structure
* /wp-content/uploads/
* /opsd_xxxxx {main dir}
* /.htaccess (Deny access and deny dir listing)
* /.index.php (Silence is golden)
* /XXXXXXXXXXXXX (Secret dir for store files)
*/
function protect_upload_dir() {
// Protected secret name LEVEL 1
$dir_level1 = $this->get_protected_dir_name();
// Install files and folders for uploading files and prevent hotlinking
$upload_dir = wp_upload_dir();
$files = array(
array(
'base' => $upload_dir['basedir'] . '/' . $dir_level1,
'file' => '.htaccess',
'content' => 'Options -Indexes' . "\n"
. 'deny from all'
)
, array(
'base' => $upload_dir['basedir'] . '/' . $dir_level1,
'file' => 'index.php',
'content' => '<?php ' . "\n"
. '// Silence is golden.'
)
);
foreach ( $files as $file ) {
if ( ( wp_mkdir_p( $file['base'] ) ) // Recursive directory creation based on full path.
&& ( ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) // If file not exist
) {
if ( $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ) ) {
fwrite( $file_handle, $file['content'] );
fclose( $file_handle );
}
}
}
}
/** Define element for opening wp media after clicking
*
* @param string $jq_selector
*/
public function set_upload_button( $jq_selector ) {
$this->settings['upload_button'] = $jq_selector;
}
/** Define element for inserting URL of file from wp media
*
* @param type $jq_selector
*/
public function set_element_insert_url( $jq_selector ) {
$this->settings['element_insert_url'] = $jq_selector;
}
public function js() {
//set JavaScript only if we set upload button
$jq_sel_upload_button = $this->get_settings( 'upload_button' );
if ( empty( $jq_sel_upload_button ) )
return;
?>
<!-- OPSD JavaScript -->
<script type="text/javascript">
var opsd_file_frame;
(function($){
//'use strict';
<?php $media_uploader_params = $this->get_settings( 'wp_media_uploader_params' ); ?>
// Our wp media frame
jQuery( '<?php echo $this->get_settings('upload_button'); ?>' ).on( 'click', function( event ) {
var j_btn = jQuery( this );
var is_multi_selection = true;
var insert_field_separator = '<?php $opsd_csv_separator = get_opsd_option( 'opsd_csv_separator' ); echo empty( $opsd_csv_separator ) ? ',' : $opsd_csv_separator; ?>';
// Stop the anchor's default behavior
event.preventDefault();
// If frame exist close it
if ( opsd_file_frame ) {
opsd_file_frame.close();
}
///////////////////////////////////////////////////////////////////////
// Create Media Frame
///////////////////////////////////////////////////////////////////////
opsd_file_frame = wp.media.frames.opsd_upload_file_frame = wp.media( { // Check here ../wp-includes/js/media-views.js
// Set the title of the modal.
title: j_btn.data( 'modal_title' ),
library: {
type: ''
},
button: {
text: j_btn.data( 'btn_title' ),
},
multiple: is_multi_selection,
states: [
new wp.media.controller.Library( {
<?php
// Add to this libaray custom post parameter: $_POST['query'][ $media_uploader_params['key'] ] = $media_uploader_params['value']
// We are checking in functon opsd_filter_posts_where media files that only relative to this medi Frame opening
// And filtering posts (in WHERE) relative custom path to our files.
// echo '{' . $media_uploader_params['key'] . ": '" . $media_uploader_params['value'] . "' }";
?>
library: wp.media.query(),
multiple: is_multi_selection,
title: j_btn.data( 'modal_title' ),
priority: 15,
filterable: 'uploaded',
//idealColumnWidth: 125
} )
]
} );
///////////////////////////////////////////////////////////////////////
// Set custom parameters for uploader -> $_POST['opsd_type'] - checking in "upload_dir", when filter_upload_dir
///////////////////////////////////////////////////////////////////////
opsd_file_frame.on( 'ready', function () {
opsd_file_frame.uploader.options.uploader.params = {
type: 'opsd_download',
<?php
echo $media_uploader_params['key'] . ": '" . $media_uploader_params['value'] . "'";
?>
};
} );
///////////////////////////////////////////////////////////////////////
// When File have selected, do this
///////////////////////////////////////////////////////////////////////
opsd_file_frame.on( 'select', function () {
if ( ! is_multi_selection ) { // Single file
var attachment = opsd_file_frame.state().get('selection').first().toJSON();
// Put URL of file to text field
j_btn.parent().find('<?php echo $this->get_settings('element_insert_url'); ?>').val( attachment.url );
} else { // Multiple files.
var file_paths = '';
var csv_data_line = '';
opsd_file_frame.state().get('selection').map( function ( attachment ) {
// Request new data
//attachment.fetch().then(function (data) {
// console.log(data);
// // preloading finished
// // after this you can use your attachment normally
// //wp.media.attachment( attachment.id ).get('url');
//});
attachment = attachment.toJSON();
//console.log( attachment );
if ( attachment.url ) {
// Insert info from selected files
csv_data_line = attachment.id + insert_field_separator + attachment.title + insert_field_separator + attachment.opsd_version_num + insert_field_separator + attachment.description + insert_field_separator + attachment.url
file_paths = file_paths ? file_paths + "\n" + csv_data_line : csv_data_line;
}
// file_paths = file_paths ? file_paths + "\n" + attachment.url : attachment.url;
});
//j_btn.parent().find('<?php echo $this->get_settings('element_insert_url'); ?>').val( file_paths );
jQuery( '#opsd_products_csv_text' ).val( file_paths + "\n\n" + jQuery( '#opsd_products_csv_text' ).val() );
}
} );
if (0) {
/** Remove Dom element of Media element from Media browser, if the URL not from our settings.
*
* @param {type} my_model_obj
* @returns {undefined}
*/
function opsd_remove_media_element_from_container( my_model_obj , delay_time ) {
/** Attributes:
'id': 112
'title': __71
'filename': 71.zip
'url': http://server.com/wp-content/uploads/opsd_lSJacOT1yVLFnrkqt2xR/2017/04/71.zip'
'link': http://server.com/__71/'
'alt':
'author': 1
'description':
'caption':
'name': __71
'status': inherit
'uploadedTo': 0
'date': Mon Apr 17 2017 14:30:32
'modified': Mon Apr 17 2017 14:30:32
'menuOrder': 0
'mime': application/zip
'type': application
'subtype': zip
'icon': http://server.com/wp-includes/images/media/archive.png
'dateFormatted': April 17, 2017
'nonces': [object Object]
'editLink': http://server.com/wp-admin/post.php?post=112&action=edit
'meta': false
'authorName': admin_name
'filesizeInBytes': 324104
'filesizeHumanReadable': 317 KB
'compat': [object Object]
*/
// Sometimes need some delay
_.delay( function() {
if ( my_model_obj.attributes.url != undefined ) {
if ( my_model_obj.attributes.url.indexOf('/<?php echo $this->get_protected_dir_name(); ?>/') === -1 ) {
//console.log( my_model_obj.attributes.url );
//wp.media.model.Attachment.get("collection").collection.remove( my_model_obj );
jQuery( "li[data-id='" + my_model_obj.attributes.id + "']" ).remove();
}
}
}, delay_time );
}
wp.media.model.Attachment.get("collection").collection.on( 'change', function( my_model_obj ) {
opsd_remove_media_element_from_container( my_model_obj , 1);
});
// Fires, when Content redraw
opsd_file_frame.on( 'content:activate:browse', function(){
var opsd_models = wp.media.model.Attachment.get("collection").collection.models;
_.each( opsd_models, function( my_model_obj, ind) {
opsd_remove_media_element_from_container( my_model_obj , 1 );
});
});
}
/*
// Fires when a state activates.
opsd_file_frame.on( 'activate', function() { alert('activate'); } );
// Fires after the frame markup has been built, but not appended to the DOM.
// @see wp.media.view.Modal.attach()
opsd_file_frame.on( 'ready', function() { alert('ready'); } );
// Fires when the frame's $el is appended to its DOM container.
// @see media.view.Modal.attach()
opsd_file_frame.on( 'attach', function() { alert('attach'); } );
// Fires when the modal opens (becomes visible).
// @see media.view.Modal.open()
opsd_file_frame.on( 'open', function() { alert('open'); } );
// Fires when the modal closes via the escape key.
// @see media.view.Modal.close()
opsd_file_frame.on( 'escape', function() { alert('escape'); } );
// Fires when the modal closes.
// @see media.view.Modal.close()
opsd_file_frame.on( 'close', function() { alert('close'); } );
// Fires when a user has selected attachment(s) and clicked the select button.
// @see media.view.MediaFrame.Post.mainInsertToolbar()
opsd_file_frame.on( 'select', function() {
var selectionCollection = opsd_file_frame.state().get('select');
} );
// Fires when a mode is deactivated on a region { 'menu' | title | content | toolbar | router }
opsd_file_frame.on( 'content:deactivate', function() { alert('{region}:deactivate'); } );
// and a more specific event including the mode.
opsd_file_frame.on( 'content:deactivate:{mode}', function() { alert('{region}:deactivate{mode}'); } );
// Fires when a region is ready for its view to be created.
opsd_file_frame.on( 'content:create', function() { alert('{region}:create'); } );
// and a more specific event including the mode.
opsd_file_frame.on( 'content:create:{mode}', function() { alert('{region}:create{mode}'); } );
// Fires when a region is ready for its view to be rendered.
opsd_file_frame.on( 'content:render', function() { alert('{region}:render'); } );
// and a more specific event including the mode.
opsd_file_frame.on( 'content:render:{mode}', function() { alert('{region}:render{mode}'); } );
// Fires when a new mode is activated (after it has been rendered) on a region.
opsd_file_frame.on( 'content:activate', function() { alert('{region}:activate'); } );
// and a more specific event including the mode.
opsd_file_frame.on( 'content:activate:{mode}', function() { alert('{region}:activate{mode}'); } );
// Get an object representing the current state.
//opsd_file_frame.state();
// Get an object representing the previous state.
//opsd_file_frame.lastState();
*/
if(0) {
// Debuge all events from media Frame!
opsd_file_frame.on("all", function(eventName) {
console.log('Frame Event: ' + eventName);
});
// Debuge all events from media Frame!
wp.media.model.Attachment.get("collection").collection.on("all", function(eventName) {
console.log('[Collection] Event: ' + eventName);
});
wp.media.model.Attachment.get("models").collection.on( "all", function(eventName) {
console.log('[models] Event: ' + eventName);
});
wp.media.model.Attachment.get("views").collection.on( "all", function(eventName) {
console.log('[views] Event: ' + eventName);
});
}
// Open the modal.
opsd_file_frame.open();
});
})(jQuery);
</script>
<!-- End OPSD JavaScript -->
<?php
}
}
/**
* The main function responsible for returning the one true Instance to functions everywhere.
*
* Example: <?php $opsd_upload = opsd_upload(); ?>
*/
function opsd_upload() {
return OPSD_Upload::init();
}
opsd_upload(); // Start
/** Add Version Number Field to Attachment Section of Media Window
*
* @param array $form_fields
* @param obj $post
* @return array
*/
function opsd_add_attachment_version_num_field( $form_fields, $post ) {
$field_value = get_post_meta( $post->ID, 'opsd_version_num', true );
$form_fields[ 'opsd_version_num' ] = array(
'value' => $field_value ? $field_value : '',
'label' => __( 'Vesion' ),
//'helps' => __( 'Set version number' )
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'opsd_add_attachment_version_num_field', 10, 2 );
/** Save Version Number as meta key relative specific attachment.
*
* @param type $attachment_id
*/
function opsd_save_attachment_version_num( $attachment_id ) {
if ( isset( $_REQUEST[ 'attachments' ][ $attachment_id ][ 'opsd_version_num' ] ) ) {
$version_num = wp_kses_post( trim( stripslashes( $_REQUEST[ 'attachments' ][ $attachment_id ][ 'opsd_version_num' ] ) ) );
update_post_meta( $attachment_id, 'opsd_version_num', $version_num );
}
}
add_action( 'edit_attachment', 'opsd_save_attachment_version_num' );
/** Get Meta key "Version Number" e.g. 'opsd_version_num' when fetching data about attachment
*
* Filters the attachment data prepared for JavaScript.
*
* @since 3.5.0
*
* @param array $response Array of prepared attachment data.
* @param int|object $attachment Attachment ID or object.
* @param array $meta Array of attachment meta data.
*/
function opsd_wp_prepare_attachment_for_js( $response, $attachment, $meta ){
if ( is_object( $attachment ) )
$attachment_id = $attachment->ID;
else
$attachment_id = $attachment;
$field_value = get_post_meta( $attachment_id, 'opsd_version_num', true );
$response[ 'opsd_version_num' ] = $field_value;
return $response;
}
add_filter('wp_prepare_attachment_for_js', 'opsd_wp_prepare_attachment_for_js' , 10, 3 );
/* we have in WP function
sanitize_file_name( $filename )
*
filename altering:
*
* so product.bl.zip become product.bl_.zip
*
*
*
* Loop over any intermediate extensions. Postfix them with a trailing underscore
* if they are a 2 - 5 character long alpha string not in the extension whitelist.
foreach ( (array) $parts as $part) {
$filename .= '.' . $part;
if ( preg_match("/^[a-zA-Z]{2,5}\d?$/", $part) ) {
$allowed = false;
foreach ( $mimes as $ext_preg => $mime_match ) {
$ext_preg = '!^(' . $ext_preg . ')$!i';
if ( preg_match( $ext_preg, $part ) ) {
$allowed = true;
break;
}
}
if ( !$allowed )
$filename .= '_';
}
}
*/
function opsd_sanitize_file_name( $filename, $filename_raw ) {
/* $filename, $filename_raw, $_REQUEST
[0] => product.bl_.zip
[1] => secure-downloads.bl.zip
[2] => Array
(
[name] => secure-downloads.bl.zip
[post_id] => 0
[_wpnonce] => 90049ce803
[type] =>
[tab] =>
[short] => 1
)
*/
return $filename;
}
// add_filter( 'sanitize_file_name', 'opsd_sanitize_file_name', 10, 2 );

View File

@@ -0,0 +1,417 @@
<?php
/**
* @version 1.0
* @package Secure Downloads
* @subpackage Core
* @category Items
*
* @author wpdevelop
* @link https://oplugins.com/
* @email info@oplugins.com
*
* @modified 2014.07.29
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'OPSD_Init' ) ) :
// General Init Class
final class OPSD_Init {
static private $instance = NULL;
public $cron;
public $notice;
public $opsd_obj;
public $admin_menu;
public $js;
public $css;
/** Get Single Instance of this Class and Init Plugin */
public static function init() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof OPSD_Init ) ) {
global $opsd_settings;
$opsd_settings = array();
self::$instance = new OPSD_Init;
self::$instance->constants();
self::$instance->includes();
self::$instance->define_version();
if ( class_exists( 'OPSD_ItemInstall' ) ) { // Check if we need to run Install / Uninstal process.
new OPSD_ItemInstall();
}
// TODO: Finish here
//add_action('plugins_loaded', array(self::$instance, 'load_textdomain') ); // T r a n s l a t i o n
$is_continue = self::$instance->start(); // Make Ajax, Response or Define item ClASS
make_opsd_action( 'opsd_calendar_started' );
do_action( 'opsd_calendar_started' );
//TODO: NEW
if ( $is_continue ) { // Possible Load Admin or Front-End page
self::$instance->js = new OPSD_JS;
self::$instance->css = new OPSD_CSS;
if( is_admin() ) {
// Define Menu
add_action( '_admin_menu', array( self::$instance, 'define_admin_menu') ); // _admin_menu - Fires before the administration menu loads in the admin.
add_action( 'admin_footer', 'opsd_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the Admin Panel page. Executed in ALL Admin Menu Pages
} else {
if ( function_exists( 'opsd_br_cache' ) ) $br_cache = opsd_br_cache(); // Init item resources cache
add_action( 'wp_enqueue_scripts', array(self::$instance->css, 'load'), 1000000001 ); // Load CSS at front-end side // Enqueue Scripts to All Client pages
add_action( 'wp_enqueue_scripts', array(self::$instance->js, 'load'), 1000000001 ); // Load JavaScript files and define JS varibales at forn-end side
add_action( 'wp_footer', 'opsd_print_js', 50 ); // Load my Queued JavaScript Code at the footer of the page, if executed "wp_footer" hook at the Theme.
}
}
}
return self::$instance;
}
/** Define Admin Menu items */
public function define_admin_menu(){
$update_count = opsd_get_number_new_items();
$title = 'Secure Downloads'; //'&#223;<span style="font-size:0.75em;">&#920;&#920;</span>&kgreen;&imath;&eng;';
if ( $update_count > 0 ){
$update_count_title = "<span class='update-plugins count-$update_count' title=''><span class='update-count bk-update-count'>" . number_format_i18n($update_count) . "</span></span>" ;
$title .= $update_count_title;
}
//global $menu;
//if ( current_user_can( ) ) {
//$menu[] = array( '', 'read', 'separator-opsd', '', 'wp-menu-separator opsd' );
//}
// debuge($menu);
$opsd_menu_position = get_opsd_option( 'opsd_menu_position' );
switch ( $opsd_menu_position ) {
case 'top':
$opsd_menu_position = 3.13;
break;
case 'middle':
global $_wp_last_object_menu; // The index of the last top-level menu in the object menu group
$_wp_last_object_menu++;
$opsd_menu_position = $_wp_last_object_menu; // 58.9;
break;
case 'bottom':
$opsd_menu_position = 99.919;
break;
default:
$opsd_menu_position = 3.13;
break;
}
// calendar3-range https://icons.getbootstrap.com/icons/calendar3-range/
// $svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar3-range" viewBox="-2 -1 20 20">'
// . '<path d="M14 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zM1 3.857C1 3.384 1.448 3 2 3h12c.552 0 1 .384 1 .857v10.286c0 .473-.448.857-1 .857H2c-.552 0-1-.384-1-.857V3.857z"/>'
// . '<path d="M7 10a1 1 0 0 0 0-2H1v2h6zm2-3h6V5H9a1 1 0 0 0 0 2z"/>'
// . '</svg>';
$svg_icon_integarted = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="opsd-upload" viewBox="-2 -3 20 20" >'
//.'<g transform="rotate(90 8 8)">' // Rotate on 90 degree where center x =8, y = 8
. '<path d="M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z"/>'
. '<path d="M7.646 1.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 2.707V11.5a.5.5 0 0 1-1 0V2.707L5.354 4.854a.5.5 0 1 1-.708-.708l3-3z"/>'
//.'</g>'
. '</svg>';
self::$instance->admin_menu['master'] = new OPSD_Admin_Menus(
'opsd' , array (
'in_menu' => 'root'
// , 'mune_icon_url' => '/assets/img/icon-16x16.png'
, 'mune_icon_url' => $svg_icon_integarted //FixIn: 2.0.1.2
, 'menu_title' => $title
, 'menu_title_second' => __('Secure Links', 'secure-downloads')
, 'page_header' => __('Secure Downlods - Generate and Send Secure Links', 'secure-downloads')
, 'browser_header' => __('Secure Downlods - Links', 'secure-downloads')
, 'user_role' => get_opsd_option( 'opsd_user_role_master' )
, 'position' => $opsd_menu_position // 3.3 - top //( 58.9 ) // - middle
/*
(Optional). Positions for Core Menu Items
2 Dashboard
4 Separator
5 Posts
10 Media
15 Links
20 Pages
25 Comments
59 Separator
60 Appearance
65 Plugins
70 Users
75 Tools
80 Settings
99 Separator
*/
)
);
self::$instance->admin_menu['files'] = new OPSD_Admin_Menus(
'opsd-files' , array (
'in_menu' => 'opsd'
, 'menu_title' => ucwords( __('Files', 'secure-downloads') )
, 'page_header' => ucwords( __('Add New', 'secure-downloads') )
, 'browser_header'=> ucwords( __('Files', 'secure-downloads') )
, 'user_role' => get_opsd_option( 'opsd_user_role_addnew' )
)
);
self::$instance->admin_menu['settings'] = new OPSD_Admin_Menus(
'opsd-settings' , array (
'in_menu' => 'opsd'
, 'menu_title' => __('Settings', 'secure-downloads')
, 'page_header' => __('General Settings', 'secure-downloads')
, 'browser_header'=> __('Settings', 'secure-downloads')
, 'user_role' => get_opsd_option( 'opsd_user_role_settings' )
)
);
}
/** Get Menu Object
*
* @param type - menu type
* @return boolean
*/
public function get_menu_object( $type ) {
if ( isset( self::$instance->admin_menu[ $type ] ) )
return self::$instance->admin_menu[ $type ];
else
return false;
}
// Define constants
private function constants() {
require_once OPSD_PLUGIN_DIR . '/core/opsd-constants.php' ;
}
// Include Files
private function includes() {
require_once OPSD_PLUGIN_DIR . '/core/opsd-include.php' ;
}
private function define_version() {
// GET VERSION NUMBER
$plugin_data = get_file_data_wpdev( OPSD_FILE , array( 'Name' => 'Plugin Name', 'PluginURI' => 'Plugin URI', 'Version' => 'Version', 'Description' => 'Description', 'Author' => 'Author', 'AuthorURI' => 'Author URI', 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path' ) , 'plugin' );
if (!defined('OPSD_VERSION')) define('OPSD_VERSION', $plugin_data['Version'] );
}
/**
* Load Plugin Locale.
* Look firstly in Global folder: /wp-content/languages/plugin_name
* then in Local folder: /wp-content/plugins/plugin_name/languages/
* and afterwards load default : load_plugin_textdomain( ...
*/
public function load_textdomain() {
// Set filter for plugin's languages directory
$plugin_lang_dir = OPSD_PLUGIN_DIR . '/languages/';
$plugin_lang_dir = apply_filters( 'opsd~languages_directory', $plugin_lang_dir );
// Plugin locale filter
$locale = apply_filters( 'plugin_locale', get_locale() , 'secure-downloads');
$mofile = sprintf( '%1$s-%2$s.mo', 'secure-downloads', $locale );
// Setup paths to current locale file
$mofile_local = $plugin_lang_dir . $mofile;
$mofile_global = WP_LANG_DIR . '/secure-downloads/' . $mofile;
if ( file_exists( $mofile_global ) ) {
// Look in global /wp-content/languages/plugin_name folder
load_textdomain( 'secure-downloads', $mofile_global );
} elseif ( file_exists( $mofile_local ) ) {
// Look in local /wp-content/plugins/plugin_name/languages/ folder
load_textdomain( 'secure-downloads', $mofile_local );
} else {
// Load the default language files
load_plugin_textdomain( 'secure-downloads', false, $plugin_lang_dir );
}
}
// Cloning instances of the class is forbidden
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Action is not allowed!' ), '1.0' );
}
// Unserializing instances of the class is forbidden
public function __wakeup() {
_doing_it_wrong( __FUNCTION__, __( 'Action is not allowed!' ), '1.0' );
}
// Initialization
private function start(){
if ( ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ){ // New A J A X R e s p o n d e r
require_once OPSD_PLUGIN_DIR . '/core/opsd-ajax.php'; // Ajax
return false;
} else { // Usual Loading of plugin
// We are having Response, its executed in other file: opsd-response.php
if ( OPSD_RESPONSE )
return false;
////////////////////////////////////////////////////////////////////
}
return true;
}
}
else: // Its seems that some instance of Secure Downloads still activted!!!
function opsd_show_activation_error() {
$message_type = 'error';
$title = __( 'Error' , 'secure-downloads') . '!';
$message = __( 'Please deactivate previous old version of' , 'secure-downloads') . ' ' . 'Item Calendar';
$opsd_version_num = get_option( 'opsd_version_num');
if ( ! empty( $opsd_version_num ) )
$message .= ' <strong>' . $opsd_version_num . '</strong>';
$is_delete_if_deactive = get_opsd_option( 'opsd_is_delete_if_deactive' ); // check
if ( $is_delete_if_deactive == 'On' ) {
$message .= '<br/><br/> <strong>Warning!</strong> ' . 'All plugin data will be deleted when plugin had deactivated.' . ' '
. sprintf( 'If you want to save your plugin data, please uncheck the %s"Delete plugin data"%s at the', '<strong>', '</strong>') . ' ' . __( 'Settings' , 'secure-downloads') . '.';
}
$message_content = '';
$message_content .= '<div class="clear"></div>';
$message_content .= '<div class="updated opsd-settings-notice notice-' . $message_type . ' ' . $message_type . '" style="text-align:left;padding:10px;">';
if ( ! empty( $title ) )
$message_content .= '<strong>' . esc_js( $title ) . '</strong> ';
$message_content .= html_entity_decode( esc_js( $message ) ,ENT_QUOTES) ;
$message_content .= '</div>';
$message_content .= '<div class="clear"></div>';
echo $message_content;
}
add_action('admin_notices', 'opsd_show_activation_error');
return; // Exit
endif;
/**
* The main function responsible for returning the one true Instance to functions everywhere.
*
* Example: <?php $opsd = OPSD(); ?>
*/
function OPSD() {
return OPSD_Init::init();
}
// Start
OPSD();
//if ( ! defined( 'SAVEQUERIES') ) define('SAVEQUERIES', true);
//add_action( 'admin_footer', 'opsd_show_debug_info', 130 );
function opsd_show_debug_info() {
$request_uri = $_SERVER['REQUEST_URI']; // FixIn:5.4.1
if ( strpos( $request_uri, 'page=opsd') === false ) {
return;
}
echo '<div style="width:800px;margin:10px auto;"><style type="text/css"> a:link{background: inherit !important; } pre { white-space: pre-wrap; }</style>';
phpinfo(); echo '</div>'; return;
?><div style="width:auto;margin:0 0 0 215px;font-size:11px; "><?php
// SYSTEM INFO SHOWING ////////////////////////////////////////////////////////
//Note firstly need to define this in functions.php file: define('SAVEQUERIES', true);
global $wpdb;
echo '<div class="clear"></div>START SYSTEM<pre>';
$qq_kk = 0;
$total_time = 0;
$total_num = 0;
foreach ( $wpdb->queries as $qq_k => $qq ) {
if (
( strpos( $qq[0], 'secure-downloads') !== false )
) {
if ( $qq[1] > 0.002 ) { echo '<div style="color:#A77;font-weight:bold;">'; }
debuge($qq_kk++, $qq);
$total_time += $qq[1];
$total_num++;
if ( $qq[1] > 0.002 ) { echo '</div>'; }
}
}
echo '<div><pre class="prettyprint linenums" style="font-size:18px;">[' . $total_num . '/' . $total_time . '] OPSD Requests TOTAL TIME</pre></div>';
echo '<div class="clear"></div>';
echo '<div><pre class="prettyprint linenums" style="font-size:18px;">' . get_num_queries(). '/' . timer_stop(0, 3) . 'qps</pre></div>';
echo '<div class="clear"></div>';
echo "</pre>";
?><br/><br/><br/><br/><br/><br/><?php
echo '<div class="clear"></div>';
////////////////////////////////////////////////////////////////////////////////
?></div><?php
echo '</div>';
}