Plugin Directory

Changeset 2965352


Ignore:
Timestamp:
09/11/2023 01:13:46 PM (2 years ago)
Author:
GermanPearls
Message:

ver 3.0.10

Location:
time-tracker/trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • time-tracker/trunk/admin/tt-admin-settings-callbacks.php

    r2957960 r2965352  
    3434function tt_categories_default_rate_callback() {
    3535    //get the value if it's already been saved
    36     $settings = get_option('time_tracker_categories');
     36    $dr = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "default_rate")));
    3737
    3838    //display on menu page
     
    4040    <div class="tt-indent">
    4141    <input type="text" id="tt-default-rate" name="time_tracker_categories[default_rate]" rows=1 cols=20 class="tt-options-form" form="tt-options"
    42     <?php $dr = trim(sanitize_textarea_field($settings['default_rate']));
     42    <?php
    4343    if (isset($dr)) {
    44         if ($dr != null) {
     44        if ($dr != null && $dr != "") {
    4545            echo " value=" . intval($dr);
    4646        }
     
    5757function tt_categories_default_currency_callback() {
    5858    //get the value if it's already been saved
    59     $settings = get_option('time_tracker_categories');
     59    $cs = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "currency_sign")));
    6060
    6161    //display on menu page
     
    6363    <div class="tt-indent">
    6464    <input type="text" id="tt-currency-sign" name="time_tracker_categories[currency_sign]" rows=1 cols=20 class="tt-options-form" form="tt-options"
    65     <?php $cs = trim(sanitize_textarea_field($settings['currency_sign']));
     65    <?php
    6666    if (isset($cs)) {
    67         if ($cs != null) {
     67        if ($cs != null && $cs != "") {
    6868            echo " value=" . esc_html($cs);
    6969        }
     
    8080 */
    8181function tt_categories_task_status_callback() {
    82     //get the value if it's already been saved to db
    83     $setting = get_option('time_tracker_categories');
    84 
    85     //display on admin page
    86     ?>
    87     <div class="tt-indent">
    88         <textarea id="tt-task-status" name="time_tracker_categories[task_status]" rows="7" cols="30" class="tt-options-form" form="tt-options"><?php
    89         $ts = trim(sanitize_textarea_field($setting['task_status']));
    90         if (isset( $ts ) && $ts <> "") {
    91             echo esc_html($ts);
    92         } else {
    93             $str = 'New
     82    //default values
     83    $str = 'New
    9484In Process
    9585Waiting Client
    9686Complete
    9787Canceled';
    98             echo $str;
    99         }
     88    //get the value if it's already been saved to db
     89    $ts = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "task_status")));
     90    if (isset( $ts )) {
     91        if ($ts != "" && $ts != null) {
     92            $str = esc_html($ts);               
     93        }
     94    }
     95
     96    //display on admin page
     97    ?>
     98    <div class="tt-indent">
     99        <textarea id="tt-task-status" name="time_tracker_categories[task_status]" rows="7" cols="30" class="tt-options-form" form="tt-options"><?php
     100        echo $str;
    100101        ?></textarea><span class="tt-options-form">List the statuses you'd like to use to keep track of your tasks.<br>
    101102        Examples: New, In Process, Waiting Client, Complete, Canceled<br>
     
    113114function tt_categories_bill_to_names_callback() {
    114115    //get the value if it's already been entered
    115     $setting = get_option('time_tracker_categories');
     116    $btn = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "bill_to_names")));
     117    $str = "";
     118    if (isset( $btn )) {
     119        $str = esc_html($btn);
     120    }
    116121
    117122    //display on menu page
     
    119124    <div class="tt-indent">
    120125    <textarea id="tt-bill-to" name="time_tracker_categories[bill_to_names]" rows="5" cols="30" class="tt-options-form" form="tt-options"><?php
    121     $btn = trim(sanitize_textarea_field($setting['bill_to_names']));
    122     if (isset( $btn )) {
    123         echo esc_html($btn);
    124     } else {
    125         echo '';
    126     }
     126    echo $str;
    127127    ?></textarea><span class="tt-options-form">Do you always bill directly to the client? Or do white-label services where you bill to a third party?<br>
    128128    Do you perform services under different business names?<br>
     
    140140function tt_categories_work_categories_callback() {
    141141    //get the value if it's already been entered
    142     $setting = get_option('time_tracker_categories');
     142    $wc = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "work_categories")));
     143    $str = "";
     144    if (isset( $wc )) {
     145        $str = esc_html($wc);
     146    }
    143147
    144148    //display on menu page
     
    146150    <div class="tt-indent">
    147151        <textarea id="tt-categories" name="time_tracker_categories[work_categories]" rows="10" cols="30" class="tt-options-form" form="tt-options"><?php
    148         $wc = trim(sanitize_textarea_field($setting['work_categories']));
    149         if (isset( $wc )) {
    150             echo esc_html($wc);
    151         } else {
    152             echo '';
    153         }
     152        echo $str;
    154153        ?></textarea><span class="tt-options-form">Time Tracker can help you keep track of different types of work.<br>
    155154        In this section, add the options you'd like to see for this field when entering a new project or task.<br>
     
    167166function tt_categories_client_categories_callback() {
    168167    //get the value if it's already been entered
    169     $setting = get_option('time_tracker_categories');
     168    $cc = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "client_categories")));
     169    $str = "";
     170    if (isset( $cc )) {
     171        $str = esc_html($cc);
     172    }
    170173
    171174    //display on menu page
     
    173176    <div class="tt-indent">
    174177        <textarea id="tt-csource" name="time_tracker_categories[client_categories]" rows="10" cols="30" class="tt-options-form" form="tt-options"><?php
    175         $cc = trim(sanitize_textarea_field($setting['client_categories']));
    176         if (isset( $cc )) {
    177             echo esc_html($cc);
    178         } else {
    179             echo '';
    180         }
     178        echo $str;
    181179        ?></textarea><span class="tt-options-form">Time Tracker will maintain information on each of your clients.<br>
    182180        When adding a new client you'll be asked to enter how they found you.<br>
     
    194192function tt_categories_client_sub_categories_callback() {
    195193    //get the value if it's already been entered
    196     $setting = get_option('time_tracker_categories');
     194    $csc = trim(sanitize_textarea_field(\Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_categories", "client_categories")));
     195    $str = "";
     196    if (isset( $csc )) {
     197        $str = esc_html($csc);
     198    }
    197199
    198200    //display on menu page
     
    200202    <div class="tt-indent">
    201203    <textarea id="tt-client-sub-categories" name="time_tracker_categories[client_sub_categories]" rows="10" cols="30" class="tt-options-form" form="tt-options"><?php
    202     $csc = sanitize_textarea_field($setting['client_sub_categories']);
    203     if (isset( $csc )) {
    204         echo esc_html($csc);
    205     } else {
    206         echo '';
    207     }
     204    echo $str;
    208205    ?></textarea><span class="tt-options-form">You can also add a second level of information on how the client found you.<br>
    209206    In this section, add the options you'd like to see for this field, one per line.<br>
     
    238235function tt_css_button_override_value() {
    239236    //get the value if it's already been entered
    240     $styles = get_option('time_tracker_style');
    241     if (is_array($styles)) {
    242         if (array_key_exists('css', $styles)) {
    243             if (is_array($styles['css'])) {
    244                 if (array_key_exists('buttons', $styles['css'])) {
    245                     if (is_array($styles['css']['buttons'])) {
    246                         if (array_key_exists('override', $styles['css']['buttons'])) {
    247                             if (trim(sanitize_textarea_field($styles['css']['buttons']['override'])) == "on") {
    248                                 return true;
    249                             }
     237    $css = \Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_style", "css");
     238    if ($css != null) {
     239        if (is_array($css)) {
     240            if (array_key_exists('buttons', $css)) {
     241                if (is_array($css['buttons'])) {
     242                    if (array_key_exists('override', $css['buttons'])) {
     243                        if (trim(sanitize_textarea_field($css['buttons']['override'])) == "on") {
     244                            return true;
    250245                        }
    251246                    }
     
    260255function tt_css_option_callback($args) {
    261256    //get the value if it's already been entered
    262     $optn = '';
    263     $styles = get_option('time_tracker_style');
    264     if (is_array($styles)) {
    265         if (array_key_exists('css', $styles)) {
    266             $optn = $styles['css'];
    267             foreach ($args as $arg) {
    268                 if (is_array($optn)) {
    269                     if (array_key_exists($arg, $optn)) {
    270                         $optn = $optn[$arg];
    271                     }
    272                 } else {
    273                     $optn = trim(sanitize_text_field($optn));
     257    $optn = "";
     258    $css = \Logically_Tech\Time_Tracker\Inc\tt_get_user_options("time_tracker_style", "css");
     259    if ($css != null) {
     260        $optn = $css;
     261        foreach ($args as $arg) {
     262            if (is_array($optn)) {
     263                if (array_key_exists($arg, $optn)) {
     264                    $optn = $optn[$arg];
    274265                }
     266            } else {
     267                $optn = trim(sanitize_text_field($optn));
    275268            }
    276269        }
  • time-tracker/trunk/inc/CF7/class-time-tracker-activator-forms-cf7.php

    r2957960 r2965352  
    229229         */
    230230        private static function get_task_status_options() {
    231             $setting = get_option('time_tracker_categories');
    232             $task_status = $setting['task_status'];
    233             if ($task_status <> "") {
     231            $task_status = \Logically_Tech\Time_Tracker\Inc\tt_get_user_options('time_tracker_categories', 'task_status');
     232            if ($task_status != "" && $task_status != null) {
    234233                $arr = explode(chr(13), $task_status);
    235234            } else {
  • time-tracker/trunk/inc/class-time-tracker-activator-pages.php

    r2957960 r2965352  
    7474        /**
    7575         * Check page exists, has correct status and matches current version
     76         * rev 3.0.10 updated to delete any existing pages (in case multiple exist due to activation errors) and create new ones
    7677         *
    7778         */
    7879        private static function check_page_exists_and_is_up_to_date($i) {
    79             //query db for page if it exists
    80             $page_exists = tt_get_page_id(self::get_page_details($i)['post_title']);
    81 
    82             //if page doesn't exist
    83             if (empty($page_exists) or $page_exists == null) {
    84                 $page_id = self::create_page(self::get_page_details($i));
    85            
    86 
    87             //page exists, make sure everything is correct
    88             } else {
    89                
    90                 $page_id = $page_exists;
    91                    
    92                 //pages are changed to draft on plugin deactivation
    93                 if (get_post_status($page_exists) == 'draft') {
    94                     self::update_page_status($page_id);
    95                 }
    96 
    97                 //check content matches current version
    98                 $installed_page = get_post($page_id);
    99                 $installed_page_content = $installed_page->post_content;
    100 
    101                 $updated_content = self::get_page_details($i)['post_content'];
    102                 //does the content match the current version
    103                 if ($installed_page_content != $updated_content) {
    104                     //update content of page in db
    105                     $updated_page = array(
    106                         'ID' => $page_id,
    107                         'post_content' => $updated_content
    108                     );
    109                     wp_update_post($updated_page);
    110                 }               
    111             }
     80            //delete any existing pages - check for multiple
     81            $page_id = tt_get_page_id(self::get_page_details($i)['post_title']);
     82            while ($page_id > 0){
     83                $result = wp_delete_post($page_id);
     84            $page_id = tt_get_page_id(self::get_page_details($i)['post_title']);
     85                log_tt_misc('page ' . self::get_page_details($i)['post_title'] . ', #' . $page_id . ' should have been deleted on plugin activation');
     86                $page_id = tt_get_page_id(self::get_page_details($i)['post_title']);
     87            }
     88           
     89            //create new page
     90            $page_id = self::create_page(self::get_page_details($i));
     91            log_tt_misc(' page ' . self::get_page_details($i)['post_title'] . ' should have been created, now is #' . $page_id);
    11292            return $page_id;
    11393        }
     
    126106        /**
    127107         * Update Page Status
     108         * @rev 3.0.10 no longer used - pages deleted on deactivation and recreated on activation
    128109         *
    129110         */
    130111        private static function update_page_status($page_id) {
    131             wp_update_post(array(
     112            add_action('init', wp_update_post(array(
    132113                'ID' => $page_id,
    133114                'post_status' => 'private'
    134             ));
     115            )), 10, 1);
    135116        }
    136117
     
    170151         *
    171152         */
    172         private static function create_homepage_details_array() {
     153        public static function create_homepage_details_array() {
    173154            $details_all = array();
    174155            //tt-home
  • time-tracker/trunk/inc/class-time-tracker-activator.php

    r2957960 r2965352  
    3030        public static function activate() {
    3131            self::define_plugin_variables();
    32             if (TT_PLUGIN_FORM_TYPE == "CF7") {
    33                 self::setup();
    34             } elseif (TT_PLUGIN_FORM_TYPE == "WPF") {
    35                 self::setup();
    36             } else {
    37                 ?>
     32            if (self::confirm_form_dependency_active() == false) { 
     33                ?>
    3834                <script type="text/javascript">
    3935                window.alert('Time Tracker requires Contact Form 7 plugin to work properly. Please install the Contact Form 7 plugin before activating Time Tracker.');
     
    4137                <?php
    4238                die('Please install the Contact Form 7 plugin before activating Time Tracker.');
    43             }
    44         }
     39                return;
     40            }
     41            if (self::check_is_block_theme()) {
     42                ?>
     43                <script type="text/javascript">
     44                window.alert('Time Tracker is not yet configured to work with block themes. Please check back for a revision soon.');
     45                </script>
     46                <?php
     47                die('Time Tracker is not yet configured to work with block themes.');
     48                return;
     49            }           
     50            self::setup();                                                                         
     51        }
     52
     53
     54        /**
     55        * Confirm form dependency active
     56        * @rev 3.0.10 added
     57        *
     58        */
     59        private static function confirm_form_dependency_active() {
     60            if (TT_PLUGIN_FORM_TYPE == "CF7") {
     61                return true;
     62            } elseif (TT_PLUGIN_FORM_TYPE == "WPF") {
     63                return true;
     64            } else {
     65                return false;
     66            }
     67        }
     68       
     69       
     70        /**
     71        * Check for block theme
     72        * @rev 3.0.10 - header/footer not yet configured for block theme and will throw error
     73        *
     74        */
     75        private static function check_is_block_theme() {
     76            if (function_exists('wp_is_block_theme')) {
     77                if (wp_is_block_theme()) {
     78                    return true;
     79                }
     80            }
     81            return false;
     82        }
    4583
    4684
     
    81119                add_option('time_tracker_categories', array('bill-to-names'=>'Client', 'work-categories'=>'Uncategorized', 'client-categories'=>'Uncategorized', 'client-sub-categories'=>'Uncategorized', 'default-client'=>print_r(self::$default_client), 'default_task'=>print_r(self::$default_task), 'default_rate'=>null));
    82120            } else {
    83                 //updates
    84121                $optns = get_option('time_tracker_categories');
    85                 if ($optns['default_client'] == null and self::$default_client != null) {
    86                     $optns['default_client'] = self::$default_client;
    87                 }
    88                 if ($optns['default_task'] == null and self::$default_task != null) {
    89                     $optns['default_task'] = self::$default_client;
    90                 }
    91                 //added in 2.5.0
    92                 if (!array_key_exists('default_rate', $optns)) {
    93                     $optns['default_rate'] = null;
    94                 }
    95                 if (!array_key_exists('currency_sign', $optns)) {
    96                     $optns['currency_sign'] = '$';
    97                 }
    98                 update_option('time_tracker_categories', $optns);
     122                //if it is there but blank add defaults
     123                if ($optns == null || $optns == "") {
     124                    add_option('time_tracker_categories', array('bill-to-names'=>'Client', 'work-categories'=>'Uncategorized', 'client-categories'=>'Uncategorized', 'client-sub-categories'=>'Uncategorized', 'default-client'=>print_r(self::$default_client), 'default_task'=>print_r(self::$default_task), 'default_rate'=>null));
     125                } else {
     126                    //add default client
     127                    if (array_key_exists("default_client", $optns)) {
     128                        if ($optns['default_client'] == null and self::$default_client != null) {
     129                            $optns['default_client'] = self::$default_client;
     130                        }
     131                    } else {
     132                        if (self::$default_client != null) {
     133                            $optns['default_client'] = self::$default_client;
     134                        }
     135                    }
     136                    //add default task
     137                    if (array_key_exists("default_task", $optns)) {
     138                        if ($optns['default_task'] == null and self::$default_task != null) {
     139                            $optns['default_task'] = self::$default_task;
     140                        }
     141                    } else {
     142                        if (self::$default_task != null) {
     143                            $optns['default_task'] = self::$default_task;
     144                        }                       
     145                    }
     146                    //added in 2.5.0 - add default rate
     147                    if (!array_key_exists('default_rate', $optns)) {
     148                        $optns['default_rate'] = null;
     149                    }
     150                    //add currency sign
     151                    if (!array_key_exists('currency_sign', $optns)) {
     152                        $optns['currency_sign'] = '$';
     153                    }
     154                    update_option('time_tracker_categories', $optns);
     155                }               
    99156            }
    100157        }
  • time-tracker/trunk/inc/class-time-tracker-deactivator.php

    r2957960 r2965352  
    3131            //self::send_deletion_warning();  WON'T NEED TO DO THIS, ONLY DURING DELETION
    3232            self::define_plugin_variables();
    33             //self::delete_tables();  DON'T REMOVE TABLES, ONLY DO THIS DURING PLUGIN DELETION ???
     33            //self::delete_tables();  DON'T REMOVE TABLES, ONLY DO THIS DURING PLUGIN DELETION
    3434            self::deactivate_crons();
    35             self::deactivate_pages();
    36             //self::delete_forms();   DON'T REMOVE FORMS, ONLY DO THIS DURING PLUGIN DELETION ???
    37            
    38             //WHAT NEEDS TO BE DONE HERE?
     35            //self::deactivate_pages();
     36            self::delete_pages();
     37            //self::delete_forms();   DON'T REMOVE FORMS, ONLY DO THIS DURING PLUGIN DELETION
    3938        }
    4039
     
    7877
    7978        /**
     79        * Get Page List in Deletion Order
     80        *
     81        */
     82        public static function get_page_list_in_deletion_order() {
     83            $tt_pages = Time_Tracker_Activator_Pages::create_subpage_details_array(1);
     84            return array_reverse($tt_pages);           
     85        }
     86       
     87       
     88        /**
     89         * Delete pages
     90         *
     91         */
     92        public static function delete_pages() {
     93            $tt_pages_delete_order = self::get_page_list_in_deletion_order();
     94            foreach ($tt_pages_delete_order as $tt_page) {
     95                self::delete_page($tt_page['Title']);
     96            }
     97            $tt_homepage = Time_Tracker_Activator_Pages::create_homepage_details_array();
     98            self::delete_page($tt_homepage['Title']);
     99        }
     100
     101
     102        /**
     103        * Delete Page
     104        *
     105        */
     106        private static function delete_page($pagename) {
     107            $post_id = tt_get_page_id($pagename);
     108            if ($post_id > 0) {
     109                $result = wp_delete_post($post_id);
     110            }           
     111        }
     112
     113
     114        /**
    80115         * Deactivate pages
    81116         *
    82117         */
    83118        public static function deactivate_pages() {
    84             $tt_pages = Time_Tracker_Activator_Pages::create_subpage_details_array(1);
    85             $tt_pages_delete_order = array_reverse($tt_pages);
    86             /**$tt_pages = array(
    87                 'time-tracker',
    88                 'clients',
    89                 'new-client',
    90                 'new-project',
    91                 'new-recurring-task',
    92                 'new-task',
    93                 'new-time-entry',
    94                 'open-task-list',
    95                 'pending-time',
    96                 'project-list',
    97                 'task-detail',
    98                 'task-list',
    99                 'time-log'
    100             );**/
     119            $tt_pages_delete_order = self::get_page_list_in_deletion_order();
    101120            foreach ($tt_pages_delete_order as $tt_page) {
    102121                self::change_page_to_draft($tt_page['Slug']);
    103122            }
     123            $tt_homepage = Time_Tracker_Activator_Pages::create_homepage_details_array();
     124            self::change_page_to_draft($tt_homepage['Slug']);
    104125        }
    105126
  • time-tracker/trunk/inc/class-time-tracker-updater.php

    r2957960 r2965352  
    155155        private function tt_update_forms($force_update = false) {
    156156            require_once(TT_PLUGIN_DIR_INC . 'class-time-tracker-activator-forms.php');
    157             require_once(TT_PLUGIN_DIR_INC . TT_PLUGIN_FORM_TYPE . '/class-time-tracker-activator-forms-' . strtolower(TT_PLUGIN_FORM_TYPE) . '.php');
     157            if (TT_PLUGIN_FORM_TYPE != null && TT_PLUGIN_FORM_TYPE != "") {
     158                require_once(TT_PLUGIN_DIR_INC . TT_PLUGIN_FORM_TYPE . '/class-time-tracker-activator-forms-' . strtolower(TT_PLUGIN_FORM_TYPE) . '.php');
     159            } else {
     160                require_once(TT_PLUGIN_DIR_INC . "CF7" . '/class-time-tracker-activator-forms-' . strtolower(TT_PLUGIN_FORM_TYPE) . '.php');
     161            }
     162           
    158163            if ($force_update) {
    159164                $tt_forms = Time_Tracker_Activator_Forms::force_form_updates();
  • time-tracker/trunk/inc/class-tt-save-form-input.php

    r2957960 r2965352  
    315315            } else {
    316316                //use default client if one exists, if not just enter null
    317                 return array_key_exists('default_client', get_option('time_tracker_categories')) ? get_option('time_tracker_categories')['default_client'] : null;
     317                return  tt_get_user_options("time_tracker_categories", "default_client");
    318318            }
    319319        }
     
    350350                return $task_number_from_string;
    351351            }
    352             return array_key_exists('default_task', get_option('time_tracker_categories')) ? get_option('time_tracker_categories')['default_task'] : null;
     352            return  tt_get_user_options("time_tracker_categories", "default_task");
    353353        }
    354354
  • time-tracker/trunk/inc/class-tt-task-list.php

    r2957960 r2965352  
    215215         */
    216216        private function get_task_status_options() {
    217             $setting = get_option('time_tracker_categories');
    218             $task_status = $setting['task_status'];
    219             if ($task_status <> "") {
     217            $task_status = tt_get_user_options("time_tracker_categories", "task_status");
     218            if ($task_status != "" && $task_status != null) {
    220219                return explode(chr(13), $task_status);
    221220            } else {
  • time-tracker/trunk/inc/css/tt-css-buttons.php

    r2957960 r2965352  
    99 **/
    1010
     11use function Logically_Tech\Time_Tracker\Inc\tt_get_user_options;
     12
    1113/** defaults **/
    1214$button_background_color = "#01375d";    //dark blue
     
    1517$button_hover_text_color = "#01375d";     //dark blue
    1618   
    17 $settings = get_option('time_tracker_style');
    18 if ($settings) {
    19     if (trim(sanitize_textarea_field($settings['css']['buttons']['override'])) == "on") {
    20         //override with user settings
    21         if (array_key_exists('css', $settings)) {
    22             if (array_key_exists('buttons', $settings['css'])) {
    23                 if (array_key_exists('background', $settings['css']['buttons'])) {
    24                     if (array_key_exists('normal', $settings['css']['buttons']['background'])) {
    25                         $button_background_color = sanitize_text_field($settings['css']['buttons']['background']['normal']);
    26                     }
    27                     if (array_key_exists('hover', $settings['css']['buttons']['background'])) {
    28                         $button_hover_background_color = sanitize_text_field($settings['css']['buttons']['background']['hover']);
     19$override = false;
     20$css = tt_get_user_options("time_tracker_style", "css");
     21
     22if ($css) {
     23    if ($css != null && $css != "") {
     24        if (is_array($css)) {
     25            if (array_key_exists("buttons", $css)) {
     26                if (is_array($css["buttons"])) {
     27                    if (array_key_exists("override", $css["buttons"])) {
     28                        if (trim(sanitize_textarea_field($css["buttons"]["override"])) == "on") {
     29                            $override = true;
     30                        }
    2931                    }
    3032                }
    31                 if (array_key_exists('text', $settings['css']['buttons'])) {
    32                     if (array_key_exists('normal', $settings['css']['buttons']['text'])) {
    33                         $button_text_color = sanitize_text_field($settings['css']['buttons']['text']['normal']);
     33            }
     34        }
     35    }
     36    if ($override) {
     37        //override with user settings
     38        if (is_array($css)) {
     39            if (array_key_exists("buttons", $css)) {
     40                if (is_array($css["buttons"])) {
     41                    //button backgrounds
     42                    if (array_key_exists("background", $css["buttons"])) {
     43                        if (is_array($css["buttons"]["background"])) {
     44                            if (array_key_exists("normal", $css["buttons"]["background"])) {
     45                                $button_background_color = sanitize_text_field($css['buttons']['background']['normal']);
     46                            }
     47                            if (array_key_exists('hover', $css['buttons']['background'])) {
     48                                $button_hover_background_color = sanitize_text_field($css['buttons']['background']['hover']);
     49                            }
     50                        }
    3451                    }
    35                     if (array_key_exists('hover', $settings['css']['buttons']['text'])) {
    36                         $button_hover_text_color = sanitize_text_field($settings['css']['buttons']['text']['hover']);
    37                     }           
    38                 } 
     52                    //button text
     53                    if (array_key_exists('text', $css['buttons'])) {
     54                        if (array_key_exists('normal', $css['buttons']['text'])) {
     55                            $button_text_color = sanitize_text_field($css['buttons']['text']['normal']);
     56                        }
     57                        if (array_key_exists('hover', $css['buttons']['text'])) {
     58                            $button_hover_text_color = sanitize_text_field($css['buttons']['text']['hover']);
     59                        }           
     60                    }
     61                }
    3962            }
    4063        }
  • time-tracker/trunk/inc/function-tt-utilities.php

    r2963193 r2965352  
    293293    //$pages = get_page_by_title($page_name, ARRAY_A);
    294294    //rev 3.0.8 get_page_by_title deprecated in WordPress 6.2
     295    //get_posts only available after plugins loaded
     296    //status must be specified or only published posts returned (not private)
     297    //to search by title use title NOT post_title
    295298    $pages = get_posts(
    296299        array(
    297300            'post_type' => 'page',
    298             'post_title' => $page_name
     301            'post_status' => get_post_statuses(),
     302            'title' => $page_name
    299303        )
    300304    );
     
    308312        }
    309313    }
    310 
    311314    return;
    312315}
     
    377380 */
    378381function tt_get_currency_type() {
    379     $optns = get_option('time_tracker_categories');
    380     if (array_key_exists('currency_sign', $optns)) {
    381         return esc_html($optns['currency_sign']);
    382     }
    383     return '';
     382    $curr = tt_get_user_options("time_tracker_categories", "currency_sign");
     383    if ($curr != null and $curr != "") {
     384        return esc_html($curr);
     385    }
     386    return "";
    384387}
    385388
     
    390393 */
    391394function tt_get_default_billing_rate() {
    392     $optns = get_option('time_tracker_categories');
    393     if ($optns) {
    394         if (array_key_exists('default_rate', $optns)) {
    395             return intval($optns['default_rate']);
    396         }
     395    $rate = tt_get_user_options("time_tracker_categories", "default_rate");
     396    if ($rate != null && $rate != "" && is_numeric($rate)) {
     397        return intval($rate);
    397398    }
    398399    return;
     
    659660function tt_get_user_options($option_name, $sub_option_name) {
    660661    $optns = get_option($option_name);
    661     if (array_key_exists($sub_option_name, $optns)) {
    662         //var_dump(nl2br($optns[$sub_option_name]));
    663         //var_dump(sanitize_text_field(nl2br($optns[$sub_option_name])));
    664         return $optns[$sub_option_name];
    665     }
    666     return "";
     662    if ($optns) {
     663        if (array_key_exists($sub_option_name, $optns)) {
     664            //var_dump(nl2br($optns[$sub_option_name]));
     665            //var_dump(sanitize_text_field(nl2br($optns[$sub_option_name])));
     666            return $optns[$sub_option_name];
     667        }
     668    }
     669    return;
    667670}
    668671
  • time-tracker/trunk/readme.txt

    r2964656 r2965352  
    66Tested up to: 6.3.1
    77Requires PHP: 7.0
    8 Stable tag: 3.0.9
     8Stable tag: 3.0.10
    99License: GPLv3 or later
    1010License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    104104== Changelog ==
    105105= 3.0.10 =
    106 Fix: Fix error on activation due to missing options not yet created
     106Improvement: Delete TT pages on plugin deactivation / Create brand new pages on re-activation
     107Improvement: Changed method for getting user settings to avoid errors when missing or not yet created
     108Fix: Added notice and prevented plugin activation on block themes as block header/footer required and not yet established in code
     109Fix: Fix error related to deprecated wp function
    107110
    108111= 3.0.9 =
  • time-tracker/trunk/time-tracker.php

    r2964656 r2965352  
    1212 * Plugin URI:        https://www.logicallytech.com/services/wordpress-plugins/time-tracker/
    1313 * Description:       A task and time tracking program. Perfect for freelancers or indivdiuals keeping track of to do lists and time worked and billed to clients.
    14  * Version:           3.0.9
     14 * Version:           3.0.10
    1515 * Requires at least: 5.3
    1616 * Requires PHP:      7.0
     
    4040 * Use SemVer - https://semver.org
    4141 */
    42 define('TIME_TRACKER_VERSION', '3.0.9');
     42define('TIME_TRACKER_VERSION', '3.0.10');
    4343define('TIME_TRACKER_PLUGIN_BASENAME', plugin_basename(__FILE__));
    4444
Note: See TracChangeset for help on using the changeset viewer.