array( 'label' => __( 'Settings', 'timesheet' ) ), 'display' => array( 'label' => __( 'Display', 'timesheet' ) ), 'reports' => array( 'label' => __( 'Reports', 'timesheet' ), 'is_pro' => 1 ), 'import-export' => array( 'label' => __( 'Import / Export', 'timesheet' ), 'is_pro' => 1 ), 'misc' => array( 'label' => __( 'Misc', 'timesheet' ) ), 'license' => array( 'label' => __( 'License Key', 'timesheet' ) ) ); parent::__construct( array( 'plugin_basename' => $plugin_basename, 'plugins_info' => $tmsht_plugin_info, 'prefix' => 'tmsht', 'default_options' => tmsht_get_options_default(), 'options' => $tmsht_options, 'tabs' => $tabs, 'wp_slug' => 'timesheet', 'pro_page' => 'admin.php?page=timesheet_pro_settings', 'bws_license_plugin' => 'timesheet-pro/timesheet-pro.php', 'link_key' => '3bdf25984ad6aa9d95074e31c5eb9bb3', 'link_pn' => '606' ) ); $this->days_arr = array( 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ); $this->date_formats = array( 'wp' => get_option( 'date_format' ), 'custom' => $this->options['date_format'] ); $this->all_roles = get_editable_roles(); ksort( $this->all_roles ); add_filter( get_parent_class( $this ) . '_additional_restore_options', array( $this, 'additional_restore_options' ) ); } /** * Save plugin options to the database * @access public * @param void * @return array The action results */ public function save_options() { global $wpdb; /* Takes all the changed settings on the plugin's admin page and saves them in array 'tmsht_options'. */ if ( isset( $_POST['tmsht_add_ts_legend'] ) ) { $ts_legend_name = ( isset( $_POST['tmsht_add_ts_legend_name'] ) ) ? esc_html( trim( $_POST['tmsht_add_ts_legend_name'] ) ) : ''; $ts_legend_color = ( isset( $_POST['tmsht_add_ts_legend_color'] ) ) ? esc_html( trim( $_POST['tmsht_add_ts_legend_color'] ) ) : ''; if ( empty( $ts_legend_name ) ) { $error = __( 'Please enter status name.', 'timesheet' ); } if ( ! preg_match( '/^#?([a-f0-9]{6}|[a-f0-9]{3})$/', $ts_legend_color ) ) { if ( empty( $error ) ) { $error .= '
' . __( 'Please choose status color.', 'timesheet' ); } else { $error .= __( 'Please choose status color.', 'timesheet' ); } } if ( empty( $error ) && $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `{$wpdb->prefix}tmsht_legends` WHERE `name` = %s OR `color` = %s", $ts_legend_name, $ts_legend_color ) ) ) { $error = sprintf( __( 'Status with name "%s" or with color %s already exists.', 'timesheet' ), $ts_legend_name, $ts_legend_color ); } if ( empty( $error ) && in_array( $ts_legend_color, array( '#ffffff', '#f9f9f9' ) ) ) { $error = sprintf( __( 'The status with the color %s can not be saved. Please choose a different color.', 'timesheet' ), $ts_legend_color ); } if ( empty( $error ) ) { $query_results = $wpdb->insert( $wpdb->prefix . "tmsht_legends", array( 'name' => $ts_legend_name, 'color' => $ts_legend_color ), array( '%s', '%s' ) ); if ( $query_results ) { unset( $ts_legend_name, $ts_legend_color ); $message = __( 'Status has been successfully added.', 'timesheet' ); } else { $error = __( 'Status has not been added.', 'timesheet' ); } } else { $error .= '
' . __( 'Status has not been added.', 'timesheet' ); } } else { /* Set timeline */ $this->options['ts_timeline_from'] = ( isset( $_POST['tmsht_ts_timeline_from'] ) && $_POST['tmsht_ts_timeline_from'] >= 0 && $_POST['tmsht_ts_timeline_from'] <= 23 ) ? intval( $_POST['tmsht_ts_timeline_from'] ) : 0; $this->options['ts_timeline_to'] = ( isset( $_POST['tmsht_ts_timeline_to'] ) && $_POST['tmsht_ts_timeline_to'] <= 24 && $_POST['tmsht_ts_timeline_to'] >= 1 ) ? intval( $_POST['tmsht_ts_timeline_to'] ) : 24; if ( $this->options['ts_timeline_from'] == $this->options['ts_timeline_to'] ) { if ( $this->options['ts_timeline_to'] < 24 ) { $this->options['ts_timeline_to']++; } else { $this->options['ts_timeline_from']--; } } /* Set weekends */ $tmsht_weekends = ( isset( $_POST['tmsht_weekends'] ) ) ? (array)$_POST['tmsht_weekends'] : array(); foreach ( $tmsht_weekends as $weekend ) { if ( ! in_array( ucfirst( $weekend ), $this->days_arr ) ) { unset( $weekend ); } $this->options['weekends'] = $tmsht_weekends; } /* Enable/disable legends */ $ts_legend_ids = ( isset( $_POST['tmsht_ts_legend_id'] ) && is_array( $_POST['tmsht_ts_legend_id'] ) ) ? $_POST['tmsht_ts_legend_id'] : array(); $ts_legend_ids_hidden = ( isset( $_POST['tmsht_ts_legend_id_hidden'] ) && is_array( $_POST['tmsht_ts_legend_id_hidden'] ) ) ? $_POST['tmsht_ts_legend_id_hidden'] : array(); foreach ( $ts_legend_ids_hidden as $legend_id ) { $color = ( isset( $_POST['tmsht_ts_legend_color'][ $legend_id ] ) && preg_match( '/^#?([a-f0-9]{6}|[a-f0-9]{3})$/', trim( $_POST['tmsht_ts_legend_color'][ $legend_id ] ) ) ) ? trim( $_POST['tmsht_ts_legend_color'][ $legend_id ] ) : false; $disabled = ( ! in_array( $legend_id, $ts_legend_ids ) ) ? 1 : 0; if ( $color ) { $wpdb->update( $wpdb->prefix . "tmsht_legends", array( 'color' => $color, 'disabled' => $disabled ), array( 'id' => $legend_id ), array( '%s', '%d' ) ); } else { $wpdb->update( $wpdb->prefix . "tmsht_legends", array( 'disabled' => $disabled ), array( 'id' => $legend_id ), array( '%d' ) ); } } /* Set date format */ if ( isset( $_POST['tmsht_date_format_type'] ) ) { switch ( $_POST['tmsht_date_format_type'] ) { case 'custom': $this->options['date_format_type'] = $_POST['tmsht_date_format_type']; $this->options['date_format'] = ( isset( $_POST['tmsht_date_format_code'] ) ) ? esc_html( trim( $_POST['tmsht_date_format_code'] ) ) : ''; break; case 'wp': $this->options['date_format_type'] = $_POST['tmsht_date_format_type']; $this->options['date_format'] = get_option( 'date_format' ); break; default: break; } } $this->options['edit_past_days'] = ( ! empty( $_POST['tmsht_edit_past_days'] ) ) ? 1 : 0; $this->options['reminder_on_email'] = ( ! empty( $_POST['tmsht_reminder_on_email'] ) ) ? 1 : 0; $this->options['day_reminder'] = ( isset( $_POST['tmsht_day_reminder'] ) && in_array( ucfirst( $_POST['tmsht_day_reminder'] ), $this->days_arr ) ) ? $_POST['tmsht_day_reminder'] : $this->default_options['day_reminder']; $this->options['time_reminder'] = ( isset( $_POST['tmsht_time_reminder'] ) && preg_match( '/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/', $_POST['tmsht_time_reminder'] ) ) ? $_POST['tmsht_time_reminder'] : $this->default_options['time_reminder']; if ( isset( $_POST['tmsht_reminder_change_state'] ) ) { wp_clear_scheduled_hook( 'tmsht_reminder_to_email' ); if ( $this->options['reminder_on_email'] ) { if ( ! wp_next_scheduled( 'tmsht_reminder_to_email' ) ) { $current_offset = get_option( 'gmt_offset' ); $tzstring = get_option( 'timezone_string' ); /* Remove old Etc mappings. Fallback to gmt_offset. */ if ( false !== strpos( $tzstring,'Etc/GMT' ) ) { $tzstring = ''; } /* Create a UTC+- zone if no timezone string exists */ if ( empty( $tzstring ) ) { if ( 0 == $current_offset ) { $tzstring = '+0'; } elseif ( $current_offset < 0 ) { $tzstring = $current_offset; } else { $tzstring = '+' . $current_offset; } } $time = strtotime( sprintf( "%s %s:00 %s", ucfirst( $this->options['day_reminder'] ), $this->options['time_reminder'], $tzstring ) ); if ( time() > $time ) { $time = strtotime( sprintf( "%s %s:00 %s +1 week", ucfirst( $this->options['day_reminder'] ), $this->options['time_reminder'], $tzstring ) ); } wp_schedule_event( $time, 'tmsht_weekly', 'tmsht_reminder_to_email' ); } } } $this->options['content_reminder']['subject'] = ( isset( $_POST['tmsht_reminder_subject'] ) ) ? wp_strip_all_tags( $_POST['tmsht_reminder_subject'] ) : $this->default_options['content_reminder']['subject']; $this->options['content_reminder']['message'] = ( isset( $_POST['tmsht_reminder_message'] ) ) ? wp_strip_all_tags( $_POST['tmsht_reminder_message'] ) : $this->default_options['content_reminder']['message']; /* Display TS user page for */ $display_ts_user_page_for = ( isset( $_POST['tmsht_display_ts_user_page_for'] ) && is_array( $_POST['tmsht_display_ts_user_page_for'] ) ) ? $_POST['tmsht_display_ts_user_page_for'] : array(); $tmsht_ts_user_roles = array(); foreach ( $display_ts_user_page_for as $role ) { if ( array_key_exists( $role, $this->all_roles ) ) { $tmsht_ts_user_roles[] = $role; } } $this->options['display_pages']['ts_user']['user_roles'] = $tmsht_ts_user_roles; /* Display TS report page for */ $display_ts_report_page_for = ( isset( $_POST['tmsht_display_ts_report_page_for'] ) && is_array( $_POST['tmsht_display_ts_report_page_for'] ) ) ? $_POST['tmsht_display_ts_report_page_for'] : array(); $ts_report_roles = array(); foreach ( $display_ts_report_page_for as $role ) { if ( array_key_exists( $role, $this->all_roles ) ) { $ts_report_roles[] = $role; } } $this->options['display_pages']['ts_report']['user_roles'] = $ts_report_roles; /* Save settings if no errors */ if ( empty( $error ) ) { update_option( 'tmsht_options', $this->options ); $message = __( 'Settings saved.', 'timesheet' ); } } return compact( 'message', 'notice', 'error' ); } /** * */ public function tab_settings() { global $wpdb; $legends = $wpdb->get_results( "SELECT * FROM `{$wpdb->prefix}tmsht_legends`", ARRAY_A ); ?>

help_phrase(); ?>
days_arr as $day ) { ?>

>
date_formats['custom'] ); ?>
.
options['edit_past_days'], 1 ); ?> />
    

:
{user_name} -
{list_days} -
{ts_page} -
{ts_page_link}Your text{/ts_page_link} -

help_phrase(); ?>
    all_roles as $role => $details ) { $users_in_role = $wpdb->get_results( "SELECT users.ID, users.user_login FROM `{$wpdb->base_prefix}users` AS users, `{$wpdb->base_prefix}usermeta` AS umeta WHERE users.ID = umeta.user_id AND umeta.meta_key = '{$wpdb->prefix}capabilities' AND umeta.meta_value LIKE '%\"{$role}\"%' ORDER BY users.ID ASC LIMIT 3", OBJECT_K ); if ( 'administrator' == $role && $this->is_multisite && ! is_main_site() ) { $super_admins = get_super_admins(); foreach ( $super_admins as $super_admin ) { $get_user = get_user_by( 'login', $super_admin ); if ( $get_user ) { $add_user = array( 'ID' => $get_user->ID, 'user_login' => $get_user->user_login ); $users_in_role[ $get_user->ID ] = (object) $add_user; } } } ksort( $users_in_role ); if ( count( $users_in_role ) > 0 ) { $checked_attr = ( in_array( $role, $this->options['display_pages']['ts_user']['user_roles'] ) ) ? 'checked="checked"' : ''; ?>
  • hide_pro_tabs ) { ?>
    bws_pro_block_links(); ?>
    all_roles as $role => $details ) { $users_in_role = $wpdb->get_results( "SELECT users.ID, users.user_login FROM `{$wpdb->base_prefix}users` AS users, `{$wpdb->base_prefix}usermeta` AS umeta WHERE users.ID = umeta.user_id AND umeta.meta_key = '{$wpdb->prefix}capabilities' AND umeta.meta_value LIKE '%\"{$role}\"%' ORDER BY users.ID ASC LIMIT 3", OBJECT_K ); if ( 'administrator' == $role && $this->is_multisite && ! is_main_site() ) { $super_admins = get_super_admins(); foreach ( $super_admins as $super_admin ) { $get_user = get_user_by( 'login', $super_admin ); if ( $get_user ) { $add_user = array( 'ID' => $get_user->ID, 'user_login' => $get_user->user_login ); $users_in_role[ $get_user->ID ] = (object) $add_user; } } } ksort( $users_in_role ); if ( count( $users_in_role ) > 0 ) { $checked_attr = ( in_array( $role, $this->options['display_pages']['ts_report']['user_roles'] ) ) ? 'checked="checked"' : ''; ?>
  • hide_pro_tabs ) { ?>
    bws_pro_block_links(); ?>

help_phrase(); ?>

:

    
bws_pro_block_links(); ?>

help_phrase(); ?>






bws_pro_block_links(); ?>
query( "UPDATE `{$wpdb->prefix}tmsht_legends` SET `disabled` = 1 WHERE `id` NOT IN ( 1,2,3,4 )" ); return $default_options; } } }