Plugin Directory

Changeset 3366280


Ignore:
Timestamp:
09/23/2025 08:14:08 AM (6 months ago)
Author:
enterrahost
Message:

Prepare release 1.0.1: updated plugin files and readme.

Location:
blue-raven
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • blue-raven/trunk/assets/js/admin-mail-form-tool.js

    r3360896 r3366280  
    556556        let title = $("#br-mf-t").text();
    557557        let formHTML = $('#mail-canvas').html();
    558 
    559         console.log(formHTML)
    560558       
    561559        let messages = {
  • blue-raven/trunk/assets/js/admin-settings.js

    r3360896 r3366280  
    134134    indicator.title = 'Checking system status...';
    135135   
    136     // =========== Create a new XMLHttpRequest for better error handling =========== //   
    137        
    138136    const xhr = new XMLHttpRequest();
    139137    xhr.open('GET', 'https://portal.enterrahost.com/systemstatus.php?t=' + Date.now(), true);
     
    149147       
    150148                const items = xmlDoc.getElementsByTagName("item");
    151                 let highestPriority = 'none';
    152        
     149                let highestPriority = 'none'; // Default to no issues
     150
     151                // Define the priority hierarchy
     152                const priorityLevels = {
     153                    'critical': 4,
     154                    'high': 3,
     155                    'medium': 2,
     156                    'low': 1
     157                };
     158                let currentHighestLevel = 0;
     159
    153160                for (let i = 0; i < items.length; i++) {
    154161                    const priorityElements = items[i].getElementsByTagName("priority");
    155162                    if (priorityElements.length > 0) {
    156                         const priority = priorityElements[0].textContent.trim().toLowerCase();
    157 
    158                         if (priority.includes('critical')) {
    159                             highestPriority = 'critical';
    160                             break;
    161                         } else if (priority.includes('medium')) {
    162                             highestPriority = 'medium';
     163                        const priorityText = priorityElements[0].textContent.trim().toLowerCase();
     164                       
     165                        // Find the matching priority level
     166                        for (const [priority, level] of Object.entries(priorityLevels)) {
     167                            if (priorityText.includes(priority)) {
     168                                if (level > currentHighestLevel) {
     169                                    currentHighestLevel = level;
     170                                    highestPriority = priority;
     171                                }
     172                                break; // Break out of the inner loop once a match is found
     173                            }
    163174                        }
     175                        // If we found a critical issue, we can break early
     176                        if (currentHighestLevel === priorityLevels.critical) break;
    164177                    }
    165178                }
    166179               
    167     // =========== Set the appropriate color =========== //
    168    
     180                // =========== Set the appropriate color =========== //
    169181                switch(highestPriority) {
    170182                    case 'critical':
    171183                        indicator.style.backgroundColor = 'red';
    172184                        indicator.title = 'Critical system issue';
    173                     break;
    174                 case 'medium':
    175                     indicator.style.backgroundColor = 'orange';
    176                     indicator.title = 'Medium system issue';
    177                     break;
    178                 default:
    179                     indicator.style.backgroundColor = 'green';
    180                     indicator.title = 'All systems operational';
     185                        break;
     186                    case 'high': // NEW CASE ADDED
     187                        indicator.style.backgroundColor = 'orange';
     188                        indicator.title = 'High priority system issue';
     189                        break;
     190                    case 'medium':
     191                        indicator.style.backgroundColor = 'orange'; // or 'yellow' for a different visual
     192                        indicator.title = 'Medium system issue';
     193                        break;
     194                    case 'low':
     195                        indicator.style.backgroundColor = 'yellow';
     196                        indicator.title = 'Low priority system issue';
     197                        break;
     198                    default:
     199                        indicator.style.backgroundColor = 'green';
     200                        indicator.title = 'All systems operational';
    181201                }
    182202            } catch (e) {
  • blue-raven/trunk/assets/js/admin.js

    r3360896 r3366280  
    124124============================================================
    125125*/
    126 
    127126(function() {
    128127    const indicator = document.getElementById('status-indicator');
     
    132131    indicator.title = 'Checking system status...';
    133132   
    134     // =========== Create a new XMLHttpRequest for better error handling =========== //   
    135        
    136133    const xhr = new XMLHttpRequest();
    137134    xhr.open('GET', 'https://portal.enterrahost.com/systemstatus.php?t=' + Date.now(), true);
     
    144141                const xmlDoc = parser.parseFromString(xhr.responseText, "text/xml");
    145142       
    146                 if (xmlDoc.getElementsByTagName("parsererror").length > 0) {throw new Error('Invalid XML format');}
     143                if (xmlDoc.getElementsByTagName("parsererror").length > 0) throw new Error('Invalid XML format');
    147144       
    148145                const items = xmlDoc.getElementsByTagName("item");
    149                 let highestPriority = 'none';
    150        
     146                let highestPriority = 'none'; // Default to no issues
     147
     148                // Define the priority hierarchy
     149                const priorityLevels = {
     150                    'critical': 4,
     151                    'high': 3,
     152                    'medium': 2,
     153                    'low': 1
     154                };
     155                let currentHighestLevel = 0;
     156
    151157                for (let i = 0; i < items.length; i++) {
    152158                    const priorityElements = items[i].getElementsByTagName("priority");
    153159                    if (priorityElements.length > 0) {
    154                         const priority = priorityElements[0].textContent.trim().toLowerCase();
    155 
    156                         if (priority.includes('critical')) {
    157                             highestPriority = 'critical';
    158                             break;
    159                         } else if (priority.includes('medium')) {
    160                             highestPriority = 'medium';
     160                        const priorityText = priorityElements[0].textContent.trim().toLowerCase();
     161                       
     162                        // Find the matching priority level
     163                        for (const [priority, level] of Object.entries(priorityLevels)) {
     164                            if (priorityText.includes(priority)) {
     165                                if (level > currentHighestLevel) {
     166                                    currentHighestLevel = level;
     167                                    highestPriority = priority;
     168                                }
     169                                break; // Break out of the inner loop once a match is found
     170                            }
    161171                        }
     172                        // If we found a critical issue, we can break early
     173                        if (currentHighestLevel === priorityLevels.critical) break;
    162174                    }
    163175                }
    164176               
    165     // =========== Set the appropriate color =========== //
    166    
     177                // =========== Set the appropriate color =========== //
    167178                switch(highestPriority) {
    168179                    case 'critical':
    169180                        indicator.style.backgroundColor = 'red';
    170181                        indicator.title = 'Critical system issue';
    171                     break;
    172                 case 'medium':
    173                     indicator.style.backgroundColor = 'orange';
    174                     indicator.title = 'Medium system issue';
    175                     break;
    176                 default:
    177                     indicator.style.backgroundColor = 'green';
    178                     indicator.title = 'All systems operational';
     182                        break;
     183                    case 'high': // NEW CASE ADDED
     184                        indicator.style.backgroundColor = 'orange';
     185                        indicator.title = 'High priority system issue';
     186                        break;
     187                    case 'medium':
     188                        indicator.style.backgroundColor = 'orange'; // or 'yellow' for a different visual
     189                        indicator.title = 'Medium system issue';
     190                        break;
     191                    case 'low':
     192                        indicator.style.backgroundColor = 'yellow';
     193                        indicator.title = 'Low priority system issue';
     194                        break;
     195                    default:
     196                        indicator.style.backgroundColor = 'green';
     197                        indicator.title = 'All systems operational';
    179198                }
    180199            } catch (e) {
  • blue-raven/trunk/blue-raven.php

    r3360896 r3366280  
    66 * Description:     Blue Raven is a fast, flexible WordPress plugin packed with free tools for SEO, site verification, analytics tag injection, and a powerful visual mail form builder with Bot protection. Manage meta, schema, robots.txt, and IndexNow with ease. Upgrade to unlock advanced features like WooCommerce product creation and optimization, uptime, domain and SSL monitoring, performance tracking, and site health alerts — all designed to help your site grow smarter.
    77 *                 
    8  * Version:         1.0.0
     8 * Version:         1.0.1
    99 * Author:          EnterraHost
    1010 * Author URI:      https://enterrahost.com
     
    298298
    299299global $wpdb;
    300 $sitemap = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}BlueRavenValues WHERE setting LIKE %s",'%site-map%'));
    301 if((!empty($sitemap) && isset($sitemap[0]->enabled) && $sitemap[0]->enabled))add_filter('wp_sitemaps_enabled', '__return_false');
    302 
     300$table_name = "{$wpdb->prefix}BlueRavenValues";
     301
     302if ($wpdb->get_var("SHOW TABLES LIKE '{$table_name}'") === $table_name) {
     303    $sitemap = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$table_name} WHERE setting LIKE %s", '%site-map%'));
     304    if (!empty($sitemap) && isset($sitemap[0]->enabled) && $sitemap[0]->enabled) add_filter('wp_sitemaps_enabled', '__return_false');
     305}
    303306/*
    304307============================================================
  • blue-raven/trunk/error_logging.php

    r3360896 r3366280  
    5959$table_name_clear = $wpdb->prefix . 'BlueRavenLogs';
    6060
    61 $wpdb->query(
    62     $wpdb->prepare(
    63         "DELETE FROM $table_name_clear WHERE created_at < %s",
    64         gmdate('Y-m-d H:i:s', strtotime('-1 month'))
    65     )
    66 );
    67 
     61if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name_clear}'" ) === $table_name_clear ) {
     62    $wpdb->query(
     63        $wpdb->prepare(
     64            "DELETE FROM $table_name_clear WHERE created_at < %s",
     65            gmdate('Y-m-d H:i:s', strtotime('-1 month'))
     66        )
     67    );
     68}
  • blue-raven/trunk/includes/admin-home.php

    r3360896 r3366280  
    5757       
    5858    if ($subaction === 'BlueRaven_loadData') {
    59         $content = isset($_POST['content']) ? array_map('sanitize_text_field', wp_unslash($_POST['content'])) : [];
    60         $range = sanitize_text_field($content[0] ?? '');
    61         $month = sanitize_text_field($content[1] ?? '');
    62        
    63         $data = array();
    64         $range_label = '';
    65         $range_type = 'month';
    66        
    67         if ($range === 'current_month') {
    68             $current_month = gmdate('m');
    69             $current_year = gmdate('Y');
    70             $days_in_month = gmdate('t');
    71             $range_label = gmdate('F Y');
    72             $data = BlueRaven_get_monthly_data($current_year, $current_month, $days_in_month);
     59
     60        if (class_exists('WooCommerce')) {
     61
     62            $content = isset($_POST['content']) ? array_map('sanitize_text_field', wp_unslash($_POST['content'])) : [];
     63            $range = sanitize_text_field($content[0] ?? '');
     64            $month = sanitize_text_field($content[1] ?? '');
     65           
     66            $data = array();
     67            $range_label = '';
     68            $range_type = 'month';
     69           
     70            if ($range === 'current_month') {
     71                $current_month = gmdate('m');
     72                $current_year = gmdate('Y');
     73                $days_in_month = gmdate('t');
     74                $range_label = gmdate('F Y');
     75                $data = BlueRaven_get_monthly_data($current_year, $current_month, $days_in_month);
     76            }
     77            elseif ($range === 'custom_month') {
     78                list($year, $month_num) = explode('-', $month);
     79                $days_in_month = gmdate('t', strtotime($month . '-01'));
     80                $range_label = gmdate('F Y', strtotime($month . '-01'));
     81                $data = BlueRaven_get_monthly_data($year, $month_num, $days_in_month);
     82            }
     83            elseif ($range === 'last_12_months') {
     84                $range_type = 'year';
     85                $current_month = gmdate('m');
     86                $current_year = gmdate('Y');
     87                $range_label = 'Last 12 Months';
     88               
     89                $labels = array();
     90                $sales_per_day = array();
     91                $revenue_per_day = array();
     92                $cumulative_revenue = array();
     93                $aov_per_day = array();
     94                $items_per_order = array();
     95                $total_revenue = 0;
     96               
     97                for ($i = 11; $i >= 0; $i--) {
     98                    $date = gmdate('Y-m', strtotime("-$i months"));
     99                    $labels[] = gmdate('M Y', strtotime($date));
     100                   
     101                    $year = gmdate('Y', strtotime($date));
     102                    $month_num = gmdate('m', strtotime($date));
     103                    $days_in_month = gmdate('t', strtotime($date . '-01'));
     104                   
     105                    $start_date = $date . '-01';
     106                    $end_date = $date . '-' . $days_in_month;
     107                   
     108                    $args = array('date_created' => $start_date . '...' . $end_date,'limit' => -1,'return' => 'objects','status' => array('completed', 'processing'));
     109                    $orders = wc_get_orders($args);
     110                    $sales_count = count($orders);
     111                    $sales_per_day[] = $sales_count;
     112                   
     113                    $monthly_revenue = 0;
     114                    $total_items = 0;
     115                   
     116                    foreach ($orders as $order) {
     117                        $monthly_revenue += $order->get_total();
     118                        $total_items += $order->get_item_count();
     119                    }
     120                   
     121                    $revenue_per_day[] = $monthly_revenue;
     122                    $total_revenue += $monthly_revenue;
     123                    $cumulative_revenue[] = $total_revenue;
     124                   
     125                    $aov = ($sales_count > 0) ? $monthly_revenue / $sales_count : 0;
     126                    $aov_per_day[] = $aov;
     127                   
     128                    $avg_items = ($sales_count > 0) ? $total_items / $sales_count : 0;
     129                    $items_per_order[] = $avg_items;
     130                }
     131               
     132                $start_date = gmdate('Y-m-01', strtotime('-11 months'));
     133                $end_date = gmdate('Y-m-t');
     134               
     135                $categories = get_terms(array(
     136                    'taxonomy' => 'product_cat',
     137                    'hide_empty' => false
     138                ));
     139               
     140                $category_labels = array();
     141                $category_sales = array();
     142                $category_colors = array();
     143               
     144                foreach ($categories as $category) {
     145                    $args = array(
     146                        'status' => array('completed', 'processing'),
     147                        'date_created' => $start_date . '...' . $end_date,
     148                        'limit' => -1
     149                    );
     150                   
     151                    $orders = wc_get_orders($args);
     152                    $category_total = 0;
     153                   
     154                    foreach ($orders as $order) {
     155                        foreach ($order->get_items() as $item) {
     156                            $product_id = $item->get_product_id();
     157                            $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
     158                            if (in_array($category->term_id, $product_categories)) $category_total += $item->get_total();
     159                        }
     160                    }
     161                   
     162                    if ($category_total > 0) {
     163                        $category_labels[] = $category->name;
     164                        $category_sales[] = $category_total;
     165                        $category_colors[] = '#' . substr(md5($category->name), 0, 6);
     166                    }
     167                }
     168               
     169                $total_units = 0;
     170                foreach ($orders as $order) {$total_units += $order->get_item_count();}
     171               
     172                $data = array(
     173                    'labels' => $labels,
     174                    'sales_per_day' => $sales_per_day,
     175                    'revenue_per_day' => $revenue_per_day,
     176                    'cumulative_revenue' => $cumulative_revenue,
     177                    'aov_per_day' => $aov_per_day,
     178                    'items_per_order' => $items_per_order,
     179                    'category_labels' => $category_labels,
     180                    'category_sales' => $category_sales,
     181                    'category_colors' => $category_colors,
     182                    'total_units' => $total_units
     183                );
     184            }
     185            elseif ($range === 'year_to_date') {
     186                $range_type = 'year';
     187                $current_year = gmdate('Y');
     188                $current_month = gmdate('m');
     189                $range_label = 'Year to Date (' . $current_year . ')';
     190               
     191                $labels = array();
     192                $sales_per_day = array();
     193                $revenue_per_day = array();
     194                $cumulative_revenue = array();
     195                $aov_per_day = array();
     196                $items_per_order = array();
     197                $total_revenue = 0;
     198               
     199                for ($i = 1; $i <= $current_month; $i++) {
     200                    $month_num = str_pad($i, 2, '0', STR_PAD_LEFT);
     201                    $labels[] = gmdate('M', strtotime($current_year . '-' . $month_num . '-01'));
     202                   
     203                    $days_in_month = gmdate('t', strtotime($current_year . '-' . $month_num . '-01'));
     204                    $start_date = $current_year . '-' . $month_num . '-01';
     205                    $end_date = $current_year . '-' . $month_num . '-' . $days_in_month;
     206                   
     207                    $args = array(
     208                        'date_created' => $start_date . '...' . $end_date,
     209                        'limit' => -1,
     210                        'return' => 'objects',
     211                        'status' => array('completed', 'processing')
     212                    );
     213                   
     214                    $orders = wc_get_orders($args);
     215                    $sales_count = count($orders);
     216                    $sales_per_day[] = $sales_count;
     217                   
     218                    $monthly_revenue = 0;
     219                    $total_items = 0;
     220                   
     221                    foreach ($orders as $order) {
     222                        $monthly_revenue += $order->get_total();
     223                        $total_items += $order->get_item_count();
     224                    }
     225                   
     226                    $revenue_per_day[] = $monthly_revenue;
     227                    $total_revenue += $monthly_revenue;
     228                    $cumulative_revenue[] = $total_revenue;
     229                   
     230                    $aov = ($sales_count > 0) ? $monthly_revenue / $sales_count : 0;
     231                    $aov_per_day[] = $aov;
     232                   
     233                    $avg_items = ($sales_count > 0) ? $total_items / $sales_count : 0;
     234                    $items_per_order[] = $avg_items;
     235                }
     236               
     237                $start_date = $current_year . '-01-01';
     238                $end_date = $current_year . '-' . $current_month . '-' . gmdate('d');
     239               
     240                $categories = get_terms(array('taxonomy' => 'product_cat','hide_empty' => false));
     241                $category_labels = array();
     242                $category_sales = array();
     243                $category_colors = array();
     244               
     245                foreach ($categories as $category) {
     246                    $args = array(
     247                        'status' => array('completed', 'processing'),
     248                        'date_created' => $start_date . '...' . $end_date,
     249                        'limit' => -1
     250                    );
     251                   
     252                    $orders = wc_get_orders($args);
     253                    $category_total = 0;
     254                   
     255                    foreach ($orders as $order) {
     256                        foreach ($order->get_items() as $item) {
     257                            $product_id = $item->get_product_id();
     258                            $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
     259                           
     260                            if (in_array($category->term_id, $product_categories)) $category_total += $item->get_total();
     261                        }
     262                    }
     263                   
     264                    if ($category_total > 0) {
     265                        $category_labels[] = $category->name;
     266                        $category_sales[] = $category_total;
     267                        $category_colors[] = '#' . substr(md5($category->name), 0, 6);
     268                    }
     269                }
     270               
     271                $total_units = 0;
     272                foreach ($orders as $order) { $total_units += $order->get_item_count();}
     273               
     274                $data = array(
     275                    'labels' => $labels,
     276                    'sales_per_day' => $sales_per_day,
     277                    'revenue_per_day' => $revenue_per_day,
     278                    'cumulative_revenue' => $cumulative_revenue,
     279                    'aov_per_day' => $aov_per_day,
     280                    'items_per_order' => $items_per_order,
     281                    'category_labels' => $category_labels,
     282                    'category_sales' => $category_sales,
     283                    'category_colors' => $category_colors,
     284                    'total_units' => $total_units
     285                );
     286            }
     287           
     288            $data['range_label'] = $range_label;
     289            $data['range_type'] = $range_type;
     290           
     291            wp_send_json_success($data);
     292        }else{
     293            wp_send_json_success([]);
    73294        }
    74         elseif ($range === 'custom_month') {
    75             list($year, $month_num) = explode('-', $month);
    76             $days_in_month = gmdate('t', strtotime($month . '-01'));
    77             $range_label = gmdate('F Y', strtotime($month . '-01'));
    78             $data = BlueRaven_get_monthly_data($year, $month_num, $days_in_month);
    79         }
    80         elseif ($range === 'last_12_months') {
    81             $range_type = 'year';
    82             $current_month = gmdate('m');
    83             $current_year = gmdate('Y');
    84             $range_label = 'Last 12 Months';
    85            
    86             $labels = array();
    87             $sales_per_day = array();
    88             $revenue_per_day = array();
    89             $cumulative_revenue = array();
    90             $aov_per_day = array();
    91             $items_per_order = array();
    92             $total_revenue = 0;
    93            
    94             for ($i = 11; $i >= 0; $i--) {
    95                 $date = gmdate('Y-m', strtotime("-$i months"));
    96                 $labels[] = gmdate('M Y', strtotime($date));
    97                
    98                 $year = gmdate('Y', strtotime($date));
    99                 $month_num = gmdate('m', strtotime($date));
    100                 $days_in_month = gmdate('t', strtotime($date . '-01'));
    101                
    102                 $start_date = $date . '-01';
    103                 $end_date = $date . '-' . $days_in_month;
    104                
    105                 $args = array('date_created' => $start_date . '...' . $end_date,'limit' => -1,'return' => 'objects','status' => array('completed', 'processing'));
    106                 $orders = wc_get_orders($args);
    107                 $sales_count = count($orders);
    108                 $sales_per_day[] = $sales_count;
    109                
    110                 $monthly_revenue = 0;
    111                 $total_items = 0;
    112                
    113                 foreach ($orders as $order) {
    114                     $monthly_revenue += $order->get_total();
    115                     $total_items += $order->get_item_count();
    116                 }
    117                
    118                 $revenue_per_day[] = $monthly_revenue;
    119                 $total_revenue += $monthly_revenue;
    120                 $cumulative_revenue[] = $total_revenue;
    121                
    122                 $aov = ($sales_count > 0) ? $monthly_revenue / $sales_count : 0;
    123                 $aov_per_day[] = $aov;
    124                
    125                 $avg_items = ($sales_count > 0) ? $total_items / $sales_count : 0;
    126                 $items_per_order[] = $avg_items;
    127             }
    128            
    129             $start_date = gmdate('Y-m-01', strtotime('-11 months'));
    130             $end_date = gmdate('Y-m-t');
    131            
    132             $categories = get_terms(array(
    133                 'taxonomy' => 'product_cat',
    134                 'hide_empty' => false
    135             ));
    136            
    137             $category_labels = array();
    138             $category_sales = array();
    139             $category_colors = array();
    140            
    141             foreach ($categories as $category) {
    142                 $args = array(
    143                     'status' => array('completed', 'processing'),
    144                     'date_created' => $start_date . '...' . $end_date,
    145                     'limit' => -1
    146                 );
    147                
    148                 $orders = wc_get_orders($args);
    149                 $category_total = 0;
    150                
    151                 foreach ($orders as $order) {
    152                     foreach ($order->get_items() as $item) {
    153                         $product_id = $item->get_product_id();
    154                         $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
    155                         if (in_array($category->term_id, $product_categories)) $category_total += $item->get_total();
    156                     }
    157                 }
    158                
    159                 if ($category_total > 0) {
    160                     $category_labels[] = $category->name;
    161                     $category_sales[] = $category_total;
    162                     $category_colors[] = '#' . substr(md5($category->name), 0, 6);
    163                 }
    164             }
    165            
    166             $total_units = 0;
    167             foreach ($orders as $order) {$total_units += $order->get_item_count();}
    168            
    169             $data = array(
    170                 'labels' => $labels,
    171                 'sales_per_day' => $sales_per_day,
    172                 'revenue_per_day' => $revenue_per_day,
    173                 'cumulative_revenue' => $cumulative_revenue,
    174                 'aov_per_day' => $aov_per_day,
    175                 'items_per_order' => $items_per_order,
    176                 'category_labels' => $category_labels,
    177                 'category_sales' => $category_sales,
    178                 'category_colors' => $category_colors,
    179                 'total_units' => $total_units
    180             );
    181         }
    182         elseif ($range === 'year_to_date') {
    183             $range_type = 'year';
    184             $current_year = gmdate('Y');
    185             $current_month = gmdate('m');
    186             $range_label = 'Year to Date (' . $current_year . ')';
    187            
    188             $labels = array();
    189             $sales_per_day = array();
    190             $revenue_per_day = array();
    191             $cumulative_revenue = array();
    192             $aov_per_day = array();
    193             $items_per_order = array();
    194             $total_revenue = 0;
    195            
    196             for ($i = 1; $i <= $current_month; $i++) {
    197                 $month_num = str_pad($i, 2, '0', STR_PAD_LEFT);
    198                 $labels[] = gmdate('M', strtotime($current_year . '-' . $month_num . '-01'));
    199                
    200                 $days_in_month = gmdate('t', strtotime($current_year . '-' . $month_num . '-01'));
    201                 $start_date = $current_year . '-' . $month_num . '-01';
    202                 $end_date = $current_year . '-' . $month_num . '-' . $days_in_month;
    203                
    204                 $args = array(
    205                     'date_created' => $start_date . '...' . $end_date,
    206                     'limit' => -1,
    207                     'return' => 'objects',
    208                     'status' => array('completed', 'processing')
    209                 );
    210                
    211                 $orders = wc_get_orders($args);
    212                 $sales_count = count($orders);
    213                 $sales_per_day[] = $sales_count;
    214                
    215                 $monthly_revenue = 0;
    216                 $total_items = 0;
    217                
    218                 foreach ($orders as $order) {
    219                     $monthly_revenue += $order->get_total();
    220                     $total_items += $order->get_item_count();
    221                 }
    222                
    223                 $revenue_per_day[] = $monthly_revenue;
    224                 $total_revenue += $monthly_revenue;
    225                 $cumulative_revenue[] = $total_revenue;
    226                
    227                 $aov = ($sales_count > 0) ? $monthly_revenue / $sales_count : 0;
    228                 $aov_per_day[] = $aov;
    229                
    230                 $avg_items = ($sales_count > 0) ? $total_items / $sales_count : 0;
    231                 $items_per_order[] = $avg_items;
    232             }
    233            
    234             $start_date = $current_year . '-01-01';
    235             $end_date = $current_year . '-' . $current_month . '-' . gmdate('d');
    236            
    237             $categories = get_terms(array('taxonomy' => 'product_cat','hide_empty' => false));
    238             $category_labels = array();
    239             $category_sales = array();
    240             $category_colors = array();
    241            
    242             foreach ($categories as $category) {
    243                 $args = array(
    244                     'status' => array('completed', 'processing'),
    245                     'date_created' => $start_date . '...' . $end_date,
    246                     'limit' => -1
    247                 );
    248                
    249                 $orders = wc_get_orders($args);
    250                 $category_total = 0;
    251                
    252                 foreach ($orders as $order) {
    253                     foreach ($order->get_items() as $item) {
    254                         $product_id = $item->get_product_id();
    255                         $product_categories = wp_get_post_terms($product_id, 'product_cat', array('fields' => 'ids'));
    256                        
    257                         if (in_array($category->term_id, $product_categories)) $category_total += $item->get_total();
    258                     }
    259                 }
    260                
    261                 if ($category_total > 0) {
    262                     $category_labels[] = $category->name;
    263                     $category_sales[] = $category_total;
    264                     $category_colors[] = '#' . substr(md5($category->name), 0, 6);
    265                 }
    266             }
    267            
    268             $total_units = 0;
    269             foreach ($orders as $order) { $total_units += $order->get_item_count();}
    270            
    271             $data = array(
    272                 'labels' => $labels,
    273                 'sales_per_day' => $sales_per_day,
    274                 'revenue_per_day' => $revenue_per_day,
    275                 'cumulative_revenue' => $cumulative_revenue,
    276                 'aov_per_day' => $aov_per_day,
    277                 'items_per_order' => $items_per_order,
    278                 'category_labels' => $category_labels,
    279                 'category_sales' => $category_sales,
    280                 'category_colors' => $category_colors,
    281                 'total_units' => $total_units
    282             );
    283         }
    284        
    285         $data['range_label'] = $range_label;
    286         $data['range_type'] = $range_type;
    287        
    288         wp_send_json_success($data);
    289295    }
    290296}
  • blue-raven/trunk/includes/admin-pages.php

    r3360896 r3366280  
    3535    ## =========== Security check =========== ##
    3636   
    37     $nonce = wp_unslash(filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_STRING) ?? '');
     37    $nonce = wp_unslash( sanitize_text_field( filter_input(INPUT_POST, 'nonce') ?? '' ) );
    3838
    3939    if (empty($nonce) || !wp_verify_nonce($nonce, 'blue_raven_admin_nonce')) {
  • blue-raven/trunk/includes/admin-products.php

    r3360896 r3366280  
    5656    if ($action === 'brand-options-page') {
    5757
    58         if (!class_exists('Blue_Raven_Admin_Brandability')) { require_once BLUERAVEN_PLUGIN_DIR . '../templates/class-admin-brand.php'; }
     58        if (!class_exists('Blue_Raven_Admin_Brandability')) { require_once BLUERAVEN_PLUGIN_DIR . '/templates/class-admin-brand.php'; }
    5959       
    6060        $pageView = new Blue_Raven_Admin_Brandability();
  • blue-raven/trunk/includes/hooks.php

    r3360896 r3366280  
    107107            switch ($result_code->setting) {
    108108                case 'google-site-analytics':
    109                     // Enqueue external script
     109                   
     110                    ///-- Enqueue external script
     111
    110112                    wp_enqueue_script(
    111113                        'google-BlueRaven_gtag',
    112                         'https://www.googletagmanager.com/BlueRaven_gtag/js?id=' . esc_attr($result_code->value),
     114                        'https://www.googletagmanager.com/gtag/js?id=' . esc_attr($result_code->value),
    113115                        [],
    114116                        null,
     
    116118                    );
    117119
    118                     // Add inline script
     120                    ///-- Add inline script
     121
    119122                    $inline = "
    120123                        window.dataLayer = window.dataLayer || [];
     
    141144
    142145                case 'meta-site-analytics':
    143                     wp_enqueue_script(
    144                         'fb-pixel',
    145                         'https://connect.facebook.net/en_US/fbevents.js',
    146                         [],
    147                         null,
    148                         false
    149                     );
    150                     $inline =
    151                     "!function(f,b,e,v,n,t,s){" .
    152                     "if(f.fbq)return;n=f.fbq=function(){n.callMethod?" .
    153                     "n.callMethod.apply(n,arguments):n.queue.push(arguments)};" .
    154                     "if(!f._fbq)f._fbq=n;" .
    155                     "n.push=n;n.loaded=!0;n.version='2.0';" .
    156                     "n.queue=[];t=b.createElement(e);t.async=!0;" .
    157                     "t.src=v;s=b.getElementsByTagName(e)[0];" .
    158                     "s.parentNode.insertBefore(t,s)}" .
    159                     "(window, document,'script'," .
    160                     "'https://connect.facebook.net/en_US/fbevents.js');" .
    161                     "fbq('init', {$result_code->value});" .
    162                     "fbq('track', 'PageView');";
    163                     wp_add_inline_script('fb-pixel', $inline);
     146                    $inline = "
     147                    !function(f,b,e,v,n,t,s){
     148                      if(f.fbq)return;n=f.fbq=function(){n.callMethod?
     149                      n.callMethod.apply(n,arguments):n.queue.push(arguments)};
     150                      if(!f._fbq)f._fbq=n;
     151                      n.push=n;n.loaded=!0;n.version='2.0';
     152                      n.queue=[];t=b.createElement(e);t.async=!0;
     153                      t.src=v;s=b.getElementsByTagName(e)[0];
     154                      s.parentNode.insertBefore(t,s)
     155                    }(window, document,'script',
     156                    'https://connect.facebook.net/en_US/fbevents.js');
     157                    fbq('init', '{$result_code->value}');
     158                    fbq('track', 'PageView');
     159                    ";
     160                    wp_register_script('fb-pixel', false);
     161                    wp_enqueue_script('fb-pixel');
     162                    wp_add_inline_script('fb-pixel', $inline);
    164163
    165164                    add_action('wp_footer', function () use ($result_code) {
     
    177176                    );
    178177
    179                     // Add data-key attribute via filter
     178                    ///-- Add data-key attribute via filter
     179                   
    180180                    add_filter('script_loader_tag', function ($tag, $handle, $src) use ($result_code) {
    181181                        if ($handle === 'ahrefs-analytics') {
  • blue-raven/trunk/includes/installer.php

    r3360896 r3366280  
    160160            dbDelta($productSQL);
    161161            update_option('blueraven_products_db_version', $products_table_version);
    162             error_log("Created new table $products_table_name");
    163162           
    164163        } else {
     
    214213            dbDelta($messagesSQL);
    215214            update_option('blueraven_messages_db_version', $messages_table_version);
    216             error_log("Created new table $messages_table_name");
    217215           
    218216        } else {
  • blue-raven/trunk/readme.md

    r3362292 r3366280  
    11=== Blue Raven ===
    22Contributors: EnterraHost
    3 Tags: SEO, WooCommerce, product descriptions, contact form, optimization
     3Tags: SEO, WooCommerce, product descriptions, alt image tags, meta, schema
    44Requires at least: 6.2
    55Tested up to: 6.8
  • blue-raven/trunk/readme.txt

    r3362292 r3366280  
    11=== Blue Raven ===
    22Contributors: EnterraHost
    3 Tags: SEO, WooCommerce, product descriptions, contact form, optimization
     3Tags: SEO, WooCommerce, product descriptions, Alt Image Tags, Meta and Schema
    44Requires at least: 6.2
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    231231== Changelog ==
    232232
    233 = 1.0.0 =
    234 Initial release – no upgrades necessary yet.
     233= 1.0.1 =
     234minior bug fixed and code enhancements
    235235
    236236== License ==
  • blue-raven/trunk/templates/blocks/block-edit-form.php

    r3360896 r3366280  
    523523    <button class='enterra-button' id='post-save-mail-block'><?php esc_html_e('Save', 'blue-raven'); ?></button>
    524524</div>
    525 
  • blue-raven/trunk/templates/tools/class-tools-sitemap.php

    r3360896 r3366280  
    1111 * 
    1212 * @Copyright       (c) 2025 EnterraHost
    13  * @Contents        Plugin Tools > Sitemap.xml
     13 * @Contents        Plugin Tools > sitemap
    1414 *
    1515 * =============================================================================
     
    8383            <?php esc_html_e("A sitemap is an XML file that lists all the important pages of your website, helping search engines like Google understand your site structure and find new or updated content faster.", 'blue-raven'); ?>
    8484            <br><br>
    85             <?php echo esc_html(isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : '') . '/sitemap.xml'; ?>
     85            <?php echo esc_html(isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : '') . '/br-sitemap.xml'; ?>
    8686            <?php esc_html_e(" — Blue Raven will update your sitemap every 24 hours if this is enabled.", 'blue-raven'); ?>
    8787        </p>
  • blue-raven/trunk/uninstall.php

    r3360896 r3366280  
    2727
    2828if ( ! defined( 'ABSPATH' ) ) exit;
    29 
    3029if (!defined('WP_UNINSTALL_PLUGIN')) exit;
    31 require_once BLUERAVEN_PLUGIN_DIR . 'error_logging.php';
    3230
    3331remove_filter('wp_sitemaps_enabled', '__return_false');
    3432
    35 BlueRaven_SendError("LOG", "blue-raven/uninstall.php", "blue_raven_remove_all_data", get_option('blue_raven_remove_all_data', false));
    3633$remove_all_data = get_option('blue_raven_remove_all_data', false);
    3734
Note: See TracChangeset for help on using the changeset viewer.