Plugin Directory

Changeset 3383367


Ignore:
Timestamp:
10/23/2025 11:55:30 AM (3 months ago)
Author:
rejaulalomkhan
Message:

Update to version 1.1.0 from GitHub

Location:
dashboard-summary
Files:
1 added
1 deleted
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dashboard-summary/tags/1.1.0/assets/css/dswp-style.css

    r3174717 r3383367  
    11.dashboard-summary {
    2     display: flex;
    3     flex-wrap: wrap;
    4     margin: 10px;
     2  display: flex;
     3  flex-wrap: wrap;
     4  margin: -5px;
     5  width: 100%;
    56}
    67
    78.dashboard-summary .card {
    8   background-color: #fff;
    9   border: 1px solid #ddd;
    10   border-radius: 10px;
     9  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     10  border: none;
     11  border-radius: 12px;
    1112  padding: 20px;
    12   margin: 10px;
    13   width: calc(16.66% - 40px);
    14   box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
     13  margin: 5px;
     14  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    1515  transition: all 0.3s ease-in-out;
    1616  display: flex;
     17  flex-direction: row;
    1718  align-items: center;
    18   justify-content: space-between;
    19   color: var(--text-color); /* use CSS variable for text color */
    20 }
    21 
    22 form div.error, .wrap .notice, .wrap div.error, .wrap div.updated {
    23     margin: 5px 0 0px !important;
     19  justify-content: flex-start;
     20  gap: 15px;
     21  color: #ffffff;
     22  text-decoration: none;
     23  flex: 1 1 calc(16.66% - 10px);
     24  box-sizing: border-box;
     25  position: relative;
     26  overflow: hidden;
     27}
     28
     29.dashboard-summary .card::before {
     30  content: '';
     31  position: absolute;
     32  top: 0;
     33  left: 0;
     34  right: 0;
     35  bottom: 0;
     36  background: rgba(255, 255, 255, 0.1);
     37  opacity: 0;
     38  transition: opacity 0.3s ease;
     39}
     40
     41.dashboard-summary .card:nth-child(1) {
     42  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
     43}
     44
     45.dashboard-summary .card:nth-child(2) {
     46  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
     47}
     48
     49.dashboard-summary .card:nth-child(3) {
     50  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
     51}
     52
     53.dashboard-summary .card:nth-child(4) {
     54  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
     55}
     56
     57.dashboard-summary .card:nth-child(5) {
     58  background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
     59}
     60
     61.dashboard-summary .card:nth-child(6) {
     62  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     63}
     64
     65.dashboard-summary a.card {
     66  text-decoration: none;
     67  color: #ffffff;
     68  cursor: pointer;
     69}
     70
     71.dashboard-summary a.card:hover::before {
     72  opacity: 1;
     73}
     74
     75form div.error,
     76.wrap .notice,
     77.wrap div.error,
     78.wrap div.updated {
     79  margin: 5px 0 0px !important;
    2480}
    2581
    2682.dashboard-summary .card-icon {
    27   font-size: 24px;
    28   margin-right: 10px;
    29   color: var(--icon-color); /* use CSS variable for icon color */
     83  font-size: 36px;
     84  margin: 0;
     85  color: rgba(255, 255, 255, 0.9);
     86  flex-shrink: 0;
     87  background: rgba(255, 255, 255, 0.2);
     88  width: 56px;
     89  height: 56px;
     90  display: flex;
     91  align-items: center;
     92  justify-content: center;
     93  border-radius: 12px;
     94  backdrop-filter: blur(10px);
     95}
     96
     97.dashboard-summary .card-content {
     98  display: flex;
     99  flex-direction: column;
     100  align-items: flex-start;
     101  gap: 5px;
     102  flex: 1;
     103}
     104
     105.dashboard-summary .card h2 {
     106  font-weight: 500;
     107  margin: 0;
     108  font-size: 13px;
     109  color: rgba(255, 255, 255, 0.9);
     110  text-transform: capitalize;
     111  letter-spacing: 0.3px;
    30112}
    31113
    32114.dashboard-summary .card-value {
    33   font-size: 24px;
     115  font-size: 28px;
     116  font-weight: 700;
     117  color: #ffffff;
     118  margin: 0;
     119  line-height: 1;
     120}
     121
     122.dashboard-summary .card:hover {
     123  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
     124  transform: translateY(-3px);
     125}
     126
     127.dashboard-summary .card p {
     128  font-size: 18px;
    34129  font-weight: bold;
    35130  color: var(--text-color); /* use CSS variable for text color */
    36131}
    37132
    38 .dashboard-summary .card:hover {
    39   background-color: #fff;
    40   border: 1px solid #ccc;
    41   box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    42   transform: translateY(-5px);
    43 }
    44 
    45 .dashboard-summary .card h2 {
    46     font-weight: bold;
    47     margin-top: 12px;
    48     color: var(--text-color); /* use CSS variable for text color */
    49 }
    50 
    51 .dashboard-summary .card p {
    52     font-size: 18px;
    53     font-weight: bold;
    54     color: var(--text-color); /* use CSS variable for text color */
    55 }
    56 
    57133/* Responsive design */
    58 @media only screen and (max-width: 768px) {
    59   .dashboard-summary .card {
    60         width: calc(50% - 40px);
    61     }
    62 }
    63 
     134
     135/* Desktop - Large screens (1200px and above) - 6 cards per row */
     136@media only screen and (min-width: 1200px) {
     137  .dashboard-summary .card {
     138    flex: 1 1 calc(16.66% - 10px);
     139    max-width: calc(16.66% - 10px);
     140  }
     141}
     142
     143/* Desktop - Medium screens (992px to 1199px) - 4 cards per row */
     144@media only screen and (min-width: 992px) and (max-width: 1199px) {
     145  .dashboard-summary .card {
     146    flex: 1 1 calc(25% - 10px);
     147    max-width: calc(25% - 10px);
     148  }
     149}
     150
     151/* Tablet - (768px to 991px) - 3 cards per row */
     152@media only screen and (min-width: 768px) and (max-width: 991px) {
     153  .dashboard-summary .card {
     154    flex: 1 1 calc(33.33% - 10px);
     155    max-width: calc(33.33% - 10px);
     156  }
     157}
     158
     159/* Mobile - Large (481px to 767px) - 2 cards per row */
     160@media only screen and (min-width: 481px) and (max-width: 767px) {
     161  .dashboard-summary {
     162    margin: -4px !important;
     163  }
     164 
     165  .dashboard-summary .card {
     166    flex: 0 1 calc(50% - 8px) !important;
     167    max-width: calc(50% - 8px) !important;
     168    min-width: calc(50% - 8px) !important;
     169    width: calc(50% - 8px) !important;
     170    margin: 4px !important;
     171    padding: 12px 10px !important;
     172    gap: 12px !important;
     173  }
     174 
     175  .dashboard-summary .card-icon {
     176    font-size: 28px !important;
     177    margin: 0 !important;
     178    width: 50px !important;
     179    height: 50px !important;
     180  }
     181 
     182  .dashboard-summary .card-content {
     183    gap: 4px !important;
     184  }
     185 
     186  .dashboard-summary .card h2 {
     187    font-size: 11px !important;
     188    margin: 0 !important;
     189  }
     190 
     191  .dashboard-summary .card-value {
     192    font-size: 24px !important;
     193    margin: 0 !important;
     194  }
     195}
     196
     197/* Mobile - Small (480px and below) - 2 cards per row */
    64198@media only screen and (max-width: 480px) {
    65   .dashboard-summary .card {
    66         width: calc(100% - 40px);
    67     }
    68 }
     199  .dashboard-summary {
     200    margin: -3px !important;
     201  }
     202 
     203  .dashboard-summary .card {
     204    flex: 0 1 calc(50% - 6px) !important;
     205    max-width: calc(50% - 6px) !important;
     206    min-width: calc(50% - 6px) !important;
     207    width: calc(50% - 6px) !important;
     208    margin: 3px !important;
     209    padding: 10px 8px !important;
     210    gap: 10px !important;
     211    border-radius: 10px !important;
     212  }
     213
     214  .dashboard-summary .card-icon {
     215    font-size: 24px !important;
     216    margin: 0 !important;
     217    width: 44px !important;
     218    height: 44px !important;
     219    border-radius: 10px !important;
     220  }
     221 
     222  .dashboard-summary .card-content {
     223    gap: 3px !important;
     224  }
     225
     226  .dashboard-summary .card h2 {
     227    font-size: 10px !important;
     228    margin: 0 !important;
     229  }
     230
     231  .dashboard-summary .card-value {
     232    font-size: 20px !important;
     233    margin: 0 !important;
     234  }
     235}
     236  }
     237}
  • dashboard-summary/tags/1.1.0/dashboard-summary.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Plugin Name: Dashboard Summary
    4  * Description: Monitor key metrics about your WooCommerce store and blog directly from your dashboard, helping you keep track of your business without navigating away from the main admin area.
     5 * Description: Beautiful, colorful dashboard cards displaying WooCommerce and blog statistics with customizable gradient colors and responsive design.
    56 * Author: Rejaul Alom Khan
    67 * Author URI: https://profiles.wordpress.org/rejaulalomkhan
     
    89 * Requires at least: 5.6
    910 * Requires PHP: 7.0
    10  * Version: 1.0.0
     11 * Version: 1.1.0
    1112 * License: GPLv2 or later
    1213 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1617
    1718// Exit if accessed directly.
    18 if ( ! defined( 'ABSPATH' ) ) {
     19if (! defined('ABSPATH')) {
    1920    exit;
    2021}
    2122
    2223// Define plugin path, URL, and basename.
    23 define( 'DSWP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    24 define( 'DSWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    25 define( 'DSWP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     24define('DSWP_PLUGIN_PATH', plugin_dir_path(__FILE__));
     25define('DSWP_PLUGIN_URL', plugin_dir_url(__FILE__));
     26define('DSWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
    2627
    2728/**
    2829 * Enqueue styles.
    2930 */
    30 function dswp_enqueue_styles() {
     31function dswp_enqueue_styles()
     32{
    3133    wp_enqueue_style(
    3234        'dashboard-summary',
     
    3537        '1.0.0'
    3638    );
     39
     40    // Add dynamic inline CSS for custom colors
     41    $custom_css = dswp_get_dynamic_css();
     42    wp_add_inline_style('dashboard-summary', $custom_css);
    3743}
    3844
    39 add_action( 'admin_enqueue_scripts', 'dswp_enqueue_styles' );
     45add_action('admin_enqueue_scripts', 'dswp_enqueue_styles');
     46
     47/**
     48 * Generate dynamic CSS from saved color settings.
     49 *
     50 * @return string Dynamic CSS.
     51 */
     52function dswp_get_dynamic_css()
     53{
     54    $options = get_option('dswp_options');
     55
     56    // Default gradient colors
     57    $defaults = array(
     58        'card1' => array('start' => '#f093fb', 'end' => '#f5576c'),
     59        'card2' => array('start' => '#4facfe', 'end' => '#00f2fe'),
     60        'card3' => array('start' => '#43e97b', 'end' => '#38f9d7'),
     61        'card4' => array('start' => '#fa709a', 'end' => '#fee140'),
     62        'card5' => array('start' => '#30cfd0', 'end' => '#330867'),
     63        'card6' => array('start' => '#667eea', 'end' => '#764ba2'),
     64    );
     65
     66    $css = '';
     67
     68    // WooCommerce cards - Normal order (1-6)
     69    for ($i = 1; $i <= 6; $i++) {
     70        $card_id = 'card' . $i;
     71        $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     72        $end_color = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     73
     74        $css .= ".dashboard-summary-woocommerce .card:nth-child({$i}) { background: linear-gradient(135deg, {$start_color} 0%, {$end_color} 100%) !important; }\n";
     75    }
     76
     77    // Blog cards - Reverse order (6-1)
     78    for ($i = 1; $i <= 6; $i++) {
     79        $reverse_index = 7 - $i; // Reverse: 1->6, 2->5, 3->4, 4->3, 5->2, 6->1
     80        $card_id = 'card' . $reverse_index;
     81        $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     82        $end_color = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     83
     84        $css .= ".dashboard-summary-blog .card:nth-child({$i}) { background: linear-gradient(135deg, {$start_color} 0%, {$end_color} 100%) !important; }\n";
     85    }
     86
     87    // Add gap between sections on desktop
     88    $css .= "@media only screen and (min-width: 768px) {\n";
     89    $css .= "  .dswp-woocommerce-section { margin-bottom: 10px !important; }\n";
     90    $css .= "  .dswp-blog-section { margin-top: 10px !important; }\n";
     91    $css .= "}\n";
     92
     93    return $css;
     94}
    4095
    4196// Include required files.
     
    48103 * @return bool True if WooCommerce is active, false otherwise.
    49104 */
    50 function dswp_is_woocommerce_active() {
    51     return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true );
     105function dswp_is_woocommerce_active()
     106{
     107    return in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')), true);
    52108}
    53109
    54110// Register activation hook.
    55 register_activation_hook( __FILE__, 'dswp_plugin_activate' );
     111register_activation_hook(__FILE__, 'dswp_plugin_activate');
    56112
    57113/**
    58114 * Activation function.
    59115 */
    60 function dswp_plugin_activate() {
    61     $options = get_option( 'dswp_options', array() );
     116function dswp_plugin_activate()
     117{
     118    $options = get_option('dswp_options', array());
    62119
    63120    // Enable blog summary by default.
     
    65122
    66123    // Check if WooCommerce is active, and if so, enable WooCommerce summary.
    67     if ( dswp_is_woocommerce_active() ) {
     124    if (dswp_is_woocommerce_active()) {
    68125        $options['enable_woocommerce'] = 1;
    69126    }
    70127
    71128    // Update the options in the database.
    72     update_option( 'dswp_options', $options );
     129    update_option('dswp_options', $options);
    73130}
    74131
     
    76133 * Initialize the plugin.
    77134 */
    78 function dswp_init_plugin() {
    79     $options = get_option( 'dswp_options' );
     135function dswp_init_plugin()
     136{
     137    $options = get_option('dswp_options');
    80138
    81     if ( isset( $options['enable_woocommerce'] ) && 1 === $options['enable_woocommerce'] && dswp_is_woocommerce_active() ) {
     139    if (isset($options['enable_woocommerce']) && 1 === $options['enable_woocommerce'] && dswp_is_woocommerce_active()) {
    82140        require_once DSWP_PLUGIN_PATH . 'includes/woocommerce-functions.php';
    83         add_action( 'wp_dashboard_setup', 'dswp_add_woocommerce_dashboard_widget' );
     141        add_action('admin_notices', 'dswp_woocommerce_summary_widget');
    84142    }
    85143
    86     if ( isset( $options['enable_blog'] ) && 1 === $options['enable_blog'] ) {
    87         add_action( 'wp_dashboard_setup', 'dswp_add_blog_dashboard_widget' );
     144    if (isset($options['enable_blog']) && 1 === $options['enable_blog']) {
     145        add_action('admin_notices', 'dswp_blog_summary_widget');
    88146    }
    89147}
    90148
    91 add_action( 'plugins_loaded', 'dswp_init_plugin' );
     149add_action('plugins_loaded', 'dswp_init_plugin');
    92150
    93151/**
    94152 * Register settings page.
    95153 */
    96 function dswp_register_settings_page() {
     154function dswp_register_settings_page()
     155{
    97156    add_options_page(
    98         __( 'Dashboard Summary Settings', 'dashboard-summary' ),
    99         __( 'Dashboard Summary', 'dashboard-summary' ),
     157        __('Dashboard Summary Settings', 'dashboard-summary'),
     158        __('Dashboard Summary', 'dashboard-summary'),
    100159        'manage_options',
    101160        'dashboard-summary-settings',
     
    104163}
    105164
    106 add_action( 'admin_menu', 'dswp_register_settings_page' );
     165add_action('admin_menu', 'dswp_register_settings_page');
  • dashboard-summary/tags/1.1.0/includes/blog-functions.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Blog Functions
     
    910
    1011/**
    11  * Add Blog Summary Widget to Dashboard.
     12 * Display the Blog Summary content on dashboard.
    1213 */
    13 function dswp_add_blog_dashboard_widget() {
    14     $options = get_option( 'dswp_options' );
    15     if ( 1 === $options['enable_blog'] ) { // Use strict comparison and Yoda condition.
    16         wp_add_dashboard_widget(
    17             'dswp_blog_summary',
    18             __( 'Blog Summary', 'dashboard-summary' ),
    19             'dswp_blog_summary_widget'
    20         );
     14function dswp_blog_summary_widget()
     15{
     16    // Only show on dashboard page
     17    $screen = get_current_screen();
     18    if (! $screen || 'dashboard' !== $screen->id) {
     19        return;
    2120    }
    22 }
    2321
    24 add_action( 'wp_dashboard_setup', 'dswp_add_blog_dashboard_widget' );
    25 
    26 /**
    27  * Display the Blog Summary Widget content.
    28  */
    29 function dswp_blog_summary_widget() {
    3022    $total_posts      = wp_count_posts()->publish;
    31     $total_pages      = wp_count_posts( 'page' )->publish;
     23    $total_pages      = wp_count_posts('page')->publish;
    3224    $total_comments   = wp_count_comments()->total_comments;
    33     $total_categories = wp_count_terms( 'category' );
    34     $total_tags       = wp_count_terms( 'post_tag' );
     25    $total_categories = wp_count_terms('category');
     26    $total_tags       = wp_count_terms('post_tag');
    3527    $total_users      = count_users()['total_users'];
    3628
    3729    // Display data.
    38     ?>
    39     <div class="notice" style="background-color: #F0F0F1; border: none;">
    40         <div class="dashboard-summary">
    41             <div class="card">
     30?>
     31    <div class="notice dswp-blog-section" style="background-color: #F0F0F1; border: none;">
     32        <div class="dashboard-summary dashboard-summary-blog">
     33            <a href="<?php echo esc_url(admin_url('edit.php')); ?>" class="card">
    4234                <i class="card-icon dashicons dashicons-admin-post"></i>
    43                 <h2><?php esc_html_e( 'Total Posts', 'dashboard-summary' ); ?></h2>
    44                 <span class="card-value"><?php echo esc_html( $total_posts ); ?></span>
    45             </div>
    46             <div class="card">
     35                <div class="card-content">
     36                    <h2><?php esc_html_e('Total Posts', 'dashboard-summary'); ?></h2>
     37                    <span class="card-value"><?php echo esc_html($total_posts); ?></span>
     38                </div>
     39            </a>
     40            <a href="<?php echo esc_url(admin_url('edit.php?post_type=page')); ?>" class="card">
    4741                <i class="card-icon dashicons dashicons-admin-page"></i>
    48                 <h2><?php esc_html_e( 'Total Pages', 'dashboard-summary' ); ?></h2>
    49                 <span class="card-value"><?php echo esc_html( $total_pages ); ?></span>
    50             </div>
    51             <div class="card">
     42                <div class="card-content">
     43                    <h2><?php esc_html_e('Total Pages', 'dashboard-summary'); ?></h2>
     44                    <span class="card-value"><?php echo esc_html($total_pages); ?></span>
     45                </div>
     46            </a>
     47            <a href="<?php echo esc_url(admin_url('edit-comments.php')); ?>" class="card">
    5248                <i class="card-icon dashicons dashicons-admin-comments"></i>
    53                 <h2><?php esc_html_e( 'Total Comments', 'dashboard-summary' ); ?></h2>
    54                 <span class="card-value"><?php echo esc_html( $total_comments ); ?></span>
    55             </div>
    56             <div class="card">
     49                <div class="card-content">
     50                    <h2><?php esc_html_e('Total Comments', 'dashboard-summary'); ?></h2>
     51                    <span class="card-value"><?php echo esc_html($total_comments); ?></span>
     52                </div>
     53            </a>
     54            <a href="<?php echo esc_url(admin_url('edit-tags.php?taxonomy=category')); ?>" class="card">
    5755                <i class="card-icon dashicons dashicons-category"></i>
    58                 <h2><?php esc_html_e( 'Total Categories', 'dashboard-summary' ); ?></h2>
    59                 <span class="card-value"><?php echo esc_html( $total_categories ); ?></span>
    60             </div>
    61             <div class="card">
     56                <div class="card-content">
     57                    <h2><?php esc_html_e('Total Categories', 'dashboard-summary'); ?></h2>
     58                    <span class="card-value"><?php echo esc_html($total_categories); ?></span>
     59                </div>
     60            </a>
     61            <a href="<?php echo esc_url(admin_url('edit-tags.php?taxonomy=post_tag')); ?>" class="card">
    6262                <i class="card-icon dashicons dashicons-tag"></i>
    63                 <h2><?php esc_html_e( 'Total Tags', 'dashboard-summary' ); ?></h2>
    64                 <span class="card-value"><?php echo esc_html( $total_tags ); ?></span>
    65             </div>
    66             <div class="card">
     63                <div class="card-content">
     64                    <h2><?php esc_html_e('Total Tags', 'dashboard-summary'); ?></h2>
     65                    <span class="card-value"><?php echo esc_html($total_tags); ?></span>
     66                </div>
     67            </a>
     68            <a href="<?php echo esc_url(admin_url('users.php')); ?>" class="card">
    6769                <i class="card-icon dashicons dashicons-admin-users"></i>
    68                 <h2><?php esc_html_e( 'Total Users', 'dashboard-summary' ); ?></h2>
    69                 <span class="card-value"><?php echo esc_html( $total_users ); ?></span>
    70             </div>
     70                <div class="card-content">
     71                    <h2><?php esc_html_e('Total Users', 'dashboard-summary'); ?></h2>
     72                    <span class="card-value"><?php echo esc_html($total_users); ?></span>
     73                </div>
     74            </a>
    7175        </div>
    7276    </div>
    73     <?php
     77<?php
    7478}
  • dashboard-summary/tags/1.1.0/includes/settings.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Dashboard Summary Settings
     
    910
    1011// Exit if accessed directly.
    11 if ( ! defined( 'ABSPATH' ) ) {
     12if (! defined('ABSPATH')) {
    1213    exit;
    1314}
    1415
    1516/**
     17 * Enqueue settings page styles.
     18 */
     19function dswp_enqueue_settings_styles($hook)
     20{
     21    if ('settings_page_dashboard-summary-settings' !== $hook) {
     22        return;
     23    }
     24    wp_enqueue_style('wp-color-picker');
     25    wp_enqueue_script('wp-color-picker');
     26}
     27add_action('admin_enqueue_scripts', 'dswp_enqueue_settings_styles');
     28
     29/**
    1630 * Register the settings for the Dashboard Summary plugin.
    1731 */
    18 function dswp_register_settings() {
    19     add_filter( 'plugin_action_links_' . DSWP_PLUGIN_BASENAME, 'dswp_add_plugin_settings_link' );
    20     register_setting( 'dswp_options_group', 'dswp_options', 'dswp_options_validate' );
     32function dswp_register_settings()
     33{
     34    add_filter('plugin_action_links_' . DSWP_PLUGIN_BASENAME, 'dswp_add_plugin_settings_link');
     35    register_setting('dswp_options_group', 'dswp_options', 'dswp_options_validate');
     36
     37    // Display Settings Section
    2138    add_settings_section(
    22         'dswp_main_section',
    23         __( 'Main Settings', 'dashboard-summary' ),
    24         'dswp_main_section_text',
     39        'dswp_display_section',
     40        __('Display Settings', 'dashboard-summary'),
     41        'dswp_display_section_text',
    2542        'dashboard-summary-settings'
    2643    );
     44
    2745    add_settings_field(
    2846        'dswp_enable_woocommerce',
    29         __( 'Enable WooCommerce Summary', 'dashboard-summary' ),
     47        __('WooCommerce Summary', 'dashboard-summary'),
    3048        'dswp_enable_woocommerce_input',
    3149        'dashboard-summary-settings',
    32         'dswp_main_section'
    33     );
     50        'dswp_display_section'
     51    );
     52
    3453    add_settings_field(
    3554        'dswp_enable_blog',
    36         __( 'Enable Blog Summary', 'dashboard-summary' ),
     55        __('Blog Summary', 'dashboard-summary'),
    3756        'dswp_enable_blog_input',
    3857        'dashboard-summary-settings',
    39         'dswp_main_section'
    40     );
    41 }
    42 
    43 add_action( 'admin_init', 'dswp_register_settings' );
     58        'dswp_display_section'
     59    );
     60
     61    // Color Settings Section
     62    add_settings_section(
     63        'dswp_color_section',
     64        __('Card Color Customization', 'dashboard-summary'),
     65        'dswp_color_section_text',
     66        'dashboard-summary-settings'
     67    );
     68
     69    // Add color pickers for each card
     70    $cards = array(
     71        'card1' => __('Card 1 Color', 'dashboard-summary'),
     72        'card2' => __('Card 2 Color', 'dashboard-summary'),
     73        'card3' => __('Card 3 Color', 'dashboard-summary'),
     74        'card4' => __('Card 4 Color', 'dashboard-summary'),
     75        'card5' => __('Card 5 Color', 'dashboard-summary'),
     76        'card6' => __('Card 6 Color', 'dashboard-summary'),
     77    );
     78
     79    foreach ($cards as $card_id => $card_label) {
     80        add_settings_field(
     81            'dswp_' . $card_id . '_colors',
     82            $card_label,
     83            'dswp_card_color_input',
     84            'dashboard-summary-settings',
     85            'dswp_color_section',
     86            array('card_id' => $card_id)
     87        );
     88    }
     89}
     90
     91add_action('admin_init', 'dswp_register_settings');
    4492
    4593/**
     
    4997 * @return array Modified plugin action links.
    5098 */
    51 function dswp_add_plugin_settings_link( $links ) {
    52     $settings_link = '<a href="options-general.php?page=dashboard-summary-settings">' . esc_html__( 'Settings', 'dashboard-summary' ) . '</a>';
    53     array_push( $links, $settings_link );
     99function dswp_add_plugin_settings_link($links)
     100{
     101    $settings_link = '<a href="options-general.php?page=dashboard-summary-settings">' . esc_html__('Settings', 'dashboard-summary') . '</a>';
     102    array_push($links, $settings_link);
    54103    return $links;
    55104}
    56105
    57106/**
    58  * Main section text for settings page.
    59  */
    60 function dswp_main_section_text() {
    61     echo '<p>' . esc_html__( 'Enable or disable dashboard summaries.', 'dashboard-summary' ) . '</p>';
    62 }
    63 
    64 /**
    65  * WooCommerce summary input checkbox.
    66  */
    67 function dswp_enable_woocommerce_input() {
    68     $options = get_option( 'dswp_options' );
    69     $checked = isset( $options['enable_woocommerce'] ) ? $options['enable_woocommerce'] : 0;
    70     echo "<input type='checkbox' name='dswp_options[enable_woocommerce]' value='1' " . checked( 1, $checked, false ) . ' />';
    71 }
    72 
    73 /**
    74  * Blog summary input checkbox.
    75  */
    76 function dswp_enable_blog_input() {
    77     $options = get_option( 'dswp_options' );
    78     $checked = isset( $options['enable_blog'] ) ? $options['enable_blog'] : 0;
    79     echo "<input type='checkbox' name='dswp_options[enable_blog]' value='1' " . checked( 1, $checked, false ) . ' />';
     107 * Display section text for settings page.
     108 */
     109function dswp_display_section_text()
     110{
     111    echo '<p class="dswp-section-description">' . esc_html__('Toggle dashboard summary widgets on or off.', 'dashboard-summary') . '</p>';
     112}
     113
     114/**
     115 * Color section text for settings page.
     116 */
     117function dswp_color_section_text()
     118{
     119    echo '<p class="dswp-section-description">' . esc_html__('Customize gradient colors for each card. Set start and end colors for the gradient effect.', 'dashboard-summary') . '</p>';
     120}
     121
     122/**
     123 * WooCommerce summary toggle switch.
     124 */
     125function dswp_enable_woocommerce_input()
     126{
     127    $options = get_option('dswp_options');
     128    $checked = isset($options['enable_woocommerce']) ? $options['enable_woocommerce'] : 0;
     129?>
     130    <label class="dswp-toggle-switch">
     131        <input type="checkbox" name="dswp_options[enable_woocommerce]" value="1" <?php checked(1, $checked); ?> />
     132        <span class="dswp-toggle-slider"></span>
     133    </label>
     134    <p class="description"><?php esc_html_e('Display WooCommerce statistics on the dashboard.', 'dashboard-summary'); ?></p>
     135<?php
     136}
     137
     138/**
     139 * Blog summary toggle switch.
     140 */
     141function dswp_enable_blog_input()
     142{
     143    $options = get_option('dswp_options');
     144    $checked = isset($options['enable_blog']) ? $options['enable_blog'] : 0;
     145?>
     146    <label class="dswp-toggle-switch">
     147        <input type="checkbox" name="dswp_options[enable_blog]" value="1" <?php checked(1, $checked); ?> />
     148        <span class="dswp-toggle-slider"></span>
     149    </label>
     150    <p class="description"><?php esc_html_e('Display blog statistics on the dashboard.', 'dashboard-summary'); ?></p>
     151<?php
     152}
     153
     154/**
     155 * Card color picker inputs.
     156 *
     157 * @param array $args Arguments containing card_id.
     158 */
     159function dswp_card_color_input($args)
     160{
     161    $options = get_option('dswp_options');
     162    $card_id = $args['card_id'];
     163
     164    // Default gradient colors
     165    $defaults = array(
     166        'card1' => array('start' => '#f093fb', 'end' => '#f5576c'),
     167        'card2' => array('start' => '#4facfe', 'end' => '#00f2fe'),
     168        'card3' => array('start' => '#43e97b', 'end' => '#38f9d7'),
     169        'card4' => array('start' => '#fa709a', 'end' => '#fee140'),
     170        'card5' => array('start' => '#30cfd0', 'end' => '#330867'),
     171        'card6' => array('start' => '#667eea', 'end' => '#764ba2'),
     172    );
     173
     174    $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     175    $end_color   = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     176?>
     177    <div class="dswp-color-picker-group">
     178        <div class="dswp-color-input">
     179            <label><?php esc_html_e('Start Color', 'dashboard-summary'); ?></label>
     180            <input type="text" name="dswp_options[<?php echo esc_attr($card_id); ?>_start]" value="<?php echo esc_attr($start_color); ?>" class="dswp-color-picker" />
     181        </div>
     182        <div class="dswp-color-input">
     183            <label><?php esc_html_e('End Color', 'dashboard-summary'); ?></label>
     184            <input type="text" name="dswp_options[<?php echo esc_attr($card_id); ?>_end]" value="<?php echo esc_attr($end_color); ?>" class="dswp-color-picker" />
     185        </div>
     186        <div class="dswp-gradient-preview" style="background: linear-gradient(135deg, <?php echo esc_attr($start_color); ?> 0%, <?php echo esc_attr($end_color); ?> 100%);"></div>
     187    </div>
     188<?php
    80189}
    81190
     
    86195 * @return array The sanitized input values.
    87196 */
    88 function dswp_options_validate( $input ) {
     197function dswp_options_validate($input)
     198{
    89199    $new_input                       = array();
    90     $new_input['enable_woocommerce'] = isset( $input['enable_woocommerce'] ) ? 1 : 0;
    91     $new_input['enable_blog']        = isset( $input['enable_blog'] ) ? 1 : 0;
     200    $new_input['enable_woocommerce'] = isset($input['enable_woocommerce']) ? 1 : 0;
     201    $new_input['enable_blog']        = isset($input['enable_blog']) ? 1 : 0;
     202
     203    // Sanitize color inputs
     204    $cards = array('card1', 'card2', 'card3', 'card4', 'card5', 'card6');
     205    foreach ($cards as $card_id) {
     206        if (isset($input[$card_id . '_start'])) {
     207            $new_input[$card_id . '_start'] = sanitize_hex_color($input[$card_id . '_start']);
     208        }
     209        if (isset($input[$card_id . '_end'])) {
     210            $new_input[$card_id . '_end'] = sanitize_hex_color($input[$card_id . '_end']);
     211        }
     212    }
     213
    92214    return $new_input;
    93215}
     
    96218 * Render the settings page for the Dashboard Summary.
    97219 */
    98 function dswp_render_settings_page() {
    99     ?>
    100     <div class="wrap">
    101         <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
    102         <form method="post" action="options.php">
    103             <?php
    104             settings_fields( 'dswp_options_group' );
    105             do_settings_sections( 'dashboard-summary-settings' );
    106             submit_button();
    107             ?>
     220function dswp_render_settings_page()
     221{
     222?>
     223    <div class="wrap dswp-settings-wrap">
     224        <div class="dswp-settings-header">
     225            <h1>
     226                <span class="dashicons dashicons-chart-area"></span>
     227                <?php echo esc_html(get_admin_page_title()); ?>
     228            </h1>
     229            <p class="dswp-subtitle"><?php esc_html_e('Customize your dashboard summary cards and display options.', 'dashboard-summary'); ?></p>
     230        </div>
     231
     232        <form method="post" action="options.php" class="dswp-settings-form">
     233            <?php settings_fields('dswp_options_group'); ?>
     234
     235            <div class="dswp-notice-info">
     236                <span class="dashicons dashicons-info"></span>
     237                <span><?php esc_html_e('Changes will take effect immediately after saving. WooCommerce cards use colors 1-6, Blog cards use colors in reverse order (6-1).', 'dashboard-summary'); ?></span>
     238            </div>
     239
     240            <?php do_settings_sections('dashboard-summary-settings'); ?>
     241
     242            <div class="dswp-submit-wrapper">
     243                <?php submit_button(__('Save Settings', 'dashboard-summary'), 'primary large', 'submit', false); ?>
     244            </div>
    108245        </form>
    109246    </div>
    110     <?php
    111 }
     247
     248    <style>
     249        /* Modern Settings Page Styles */
     250        .dswp-settings-wrap {
     251            max-width: 1200px;
     252            margin: 20px 0;
     253        }
     254
     255        .dswp-settings-header {
     256            background: #ffffff;
     257            border-left: 4px solid #667eea;
     258            padding: 20px 30px;
     259            border-radius: 8px;
     260            margin-bottom: 25px;
     261            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
     262        }
     263
     264        .dswp-settings-header h1 {
     265            color: #333;
     266            font-size: 26px;
     267            margin: 0 0 8px 0;
     268            display: flex;
     269            align-items: center;
     270            gap: 12px;
     271        }
     272
     273        .dswp-settings-header h1 .dashicons {
     274            font-size: 28px;
     275            width: 28px;
     276            height: 28px;
     277            color: #667eea;
     278        }
     279
     280        .dswp-subtitle {
     281            margin: 0;
     282            color: #666;
     283            font-size: 14px;
     284        }
     285
     286        /* Notice Info Box */
     287        .dswp-notice-info {
     288            background: #e7f3ff;
     289            border-left: 4px solid #2196f3;
     290            padding: 15px 20px;
     291            margin: 20px 0;
     292            border-radius: 4px;
     293            display: flex;
     294            align-items: flex-start;
     295            gap: 12px;
     296        }
     297
     298        .dswp-notice-info .dashicons {
     299            color: #2196f3;
     300            font-size: 20px;
     301            width: 20px;
     302            height: 20px;
     303            flex-shrink: 0;
     304            margin-top: 2px;
     305        }
     306
     307        .dswp-notice-info span:not(.dashicons) {
     308            color: #0c5ba8;
     309            font-size: 14px;
     310            line-height: 1.6;
     311        }
     312
     313        .dswp-settings-form h2 {
     314            background: #f8f9fa;
     315            padding: 15px 20px;
     316            border-left: 4px solid #667eea;
     317            margin: 30px 0 20px 0;
     318            font-size: 18px;
     319            border-radius: 4px;
     320        }
     321
     322        .dswp-section-description {
     323            color: #666;
     324            font-size: 14px;
     325            margin: -10px 0 20px 0;
     326        }
     327
     328        /* Toggle Switch Styles */
     329        .dswp-toggle-switch {
     330            position: relative;
     331            display: inline-block;
     332            width: 54px;
     333            height: 28px;
     334            margin-right: 10px;
     335        }
     336
     337        .dswp-toggle-switch input {
     338            opacity: 0;
     339            width: 0;
     340            height: 0;
     341        }
     342
     343        .dswp-toggle-slider {
     344            position: absolute;
     345            cursor: pointer;
     346            top: 0;
     347            left: 0;
     348            right: 0;
     349            bottom: 0;
     350            background-color: #ccc;
     351            transition: 0.3s;
     352            border-radius: 28px;
     353        }
     354
     355        .dswp-toggle-slider:before {
     356            position: absolute;
     357            content: "";
     358            height: 20px;
     359            width: 20px;
     360            left: 4px;
     361            bottom: 4px;
     362            background-color: white;
     363            transition: 0.3s;
     364            border-radius: 50%;
     365        }
     366
     367        .dswp-toggle-switch input:checked+.dswp-toggle-slider {
     368            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     369        }
     370
     371        .dswp-toggle-switch input:checked+.dswp-toggle-slider:before {
     372            transform: translateX(26px);
     373        }
     374
     375        .dswp-toggle-switch input:focus+.dswp-toggle-slider {
     376            box-shadow: 0 0 1px #667eea;
     377        }
     378
     379        /* Color Picker Group Styles */
     380        .dswp-color-picker-group {
     381            display: flex;
     382            gap: 20px;
     383            align-items: flex-start;
     384            flex-wrap: wrap;
     385        }
     386
     387        .dswp-color-input {
     388            display: flex;
     389            flex-direction: column;
     390            gap: 8px;
     391        }
     392
     393        .dswp-color-input label {
     394            font-weight: 500;
     395            font-size: 13px;
     396            color: #555;
     397        }
     398
     399        .dswp-color-picker {
     400            width: 100px !important;
     401        }
     402
     403        .dswp-gradient-preview {
     404            width: 150px;
     405            height: 40px;
     406            border-radius: 8px;
     407            border: 2px solid #e0e0e0;
     408            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
     409        }
     410
     411        .form-table th {
     412            width: 220px;
     413            font-weight: 600;
     414            color: #333;
     415        }
     416
     417        .form-table td {
     418            padding: 20px 10px;
     419        }
     420
     421        .form-table td .description {
     422            margin-top: 8px;
     423            font-style: italic;
     424            color: #666;
     425        }
     426
     427        /* Submit Button */
     428        .dswp-submit-wrapper {
     429            margin-top: 30px;
     430            padding-top: 20px;
     431            border-top: 1px solid #e0e0e0;
     432        }
     433
     434        .dswp-submit-wrapper .button-primary {
     435            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     436            border: none;
     437            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
     438            text-shadow: none;
     439            padding: 8px 30px;
     440            height: auto;
     441            font-size: 15px;
     442            transition: all 0.3s ease;
     443        }
     444
     445        .dswp-submit-wrapper .button-primary:hover {
     446            background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
     447            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
     448            transform: translateY(-2px);
     449        }
     450
     451        .dswp-submit-wrapper .button-primary:active {
     452            transform: translateY(0);
     453        }
     454    </style>
     455
     456    <script>
     457        jQuery(document).ready(function($) {
     458            // Initialize color pickers
     459            $('.dswp-color-picker').wpColorPicker({
     460                change: function(event, ui) {
     461                    var element = $(this).closest('.dswp-color-picker-group');
     462                    var startColor = element.find('input[name*="_start"]').val();
     463                    var endColor = element.find('input[name*="_end"]').val();
     464                    element.find('.dswp-gradient-preview').css('background', 'linear-gradient(135deg, ' + startColor + ' 0%, ' + endColor + ' 100%)');
     465                }
     466            });
     467        });
     468    </script>
     469<?php
     470}
  • dashboard-summary/tags/1.1.0/includes/woocommerce-functions.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * WooCommerce Summary Widget
     
    910
    1011/**
    11  * Adds the WooCommerce Summary Widget to the dashboard.
     12 * Displays the WooCommerce Summary content on dashboard.
    1213 */
    13 function dswp_add_woocommerce_dashboard_widget() {
    14     $options = get_option( 'dswp_options' );
    15     if ( isset( $options['enable_woocommerce'] ) && 1 === $options['enable_woocommerce'] ) { // Use strict comparison and Yoda condition.
    16         wp_add_dashboard_widget(
    17             'dswp_woocommerce_summary',
    18             __( 'WooCommerce Summary', 'dashboard-summary' ),
    19             'dswp_woocommerce_summary_widget'
    20         );
     14function dswp_woocommerce_summary_widget()
     15{
     16    // Only show on dashboard page
     17    $screen = get_current_screen();
     18    if (! $screen || 'dashboard' !== $screen->id) {
     19        return;
    2120    }
    22 }
    2321
    24 add_action( 'wp_dashboard_setup', 'dswp_add_woocommerce_dashboard_widget' );
    25 
    26 /**
    27  * Displays the content of the WooCommerce Summary Widget.
    28  */
    29 function dswp_woocommerce_summary_widget() {
    3022    // Get WooCommerce data.
    31     $orders           = wc_get_orders( array( 'status' => 'any' ) );
    32     $total_orders     = count( $orders );
    33     $pending_orders   = wc_get_orders( array( 'status' => 'processing' ) );
    34     $total_pending    = count( $pending_orders );
    35     $on_hold_orders   = wc_get_orders( array( 'status' => 'on-hold' ) );
    36     $total_on_hold    = count( $on_hold_orders );
    37     $completed_orders = wc_get_orders( array( 'status' => 'completed' ) );
    38     $total_completed  = count( $completed_orders );
    39     $total_customers  = count( get_users( array( 'role' => 'customer' ) ) );
    40     $total_products   = wp_count_posts( 'product' )->publish;
     23    $orders           = wc_get_orders(array('status' => 'any'));
     24    $total_orders     = count($orders);
     25    $pending_orders   = wc_get_orders(array('status' => 'processing'));
     26    $total_pending    = count($pending_orders);
     27    $on_hold_orders   = wc_get_orders(array('status' => 'on-hold'));
     28    $total_on_hold    = count($on_hold_orders);
     29    $completed_orders = wc_get_orders(array('status' => 'completed'));
     30    $total_completed  = count($completed_orders);
     31    $total_customers  = count(get_users(array('role' => 'customer')));
     32    $total_products   = wp_count_posts('product')->publish;
    4133
    4234    // Display data.
    43     ?>
    44     <div class="notice" style="background-color: #F0F0F1; border: none;">
    45         <div class="dashboard-summary">
    46             <div class="card">
     35?>
     36    <div class="notice dswp-woocommerce-section" style="background-color: #F0F0F1; border: none;">
     37        <div class="dashboard-summary dashboard-summary-woocommerce">
     38            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order')); ?>" class="card">
    4739                <i class="card-icon dashicons dashicons-chart-bar"></i>
    48                 <h2><?php esc_html_e( 'Total Orders', 'dashboard-summary' ); ?></h2>
    49                 <span class="card-value"><?php echo esc_html( $total_orders ); ?></span>
    50             </div>
    51             <div class="card">
     40                <div class="card-content">
     41                    <h2><?php esc_html_e('Total Orders', 'dashboard-summary'); ?></h2>
     42                    <span class="card-value"><?php echo esc_html($total_orders); ?></span>
     43                </div>
     44            </a>
     45            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-processing')); ?>" class="card">
    5246                <i class="card-icon dashicons dashicons-clock"></i>
    53                 <h2><?php esc_html_e( 'Pending Orders', 'dashboard-summary' ); ?></h2>
    54                 <span class="card-value"><?php echo esc_html( $total_pending ); ?></span>
    55             </div>
    56             <div class="card">
     47                <div class="card-content">
     48                    <h2><?php esc_html_e('Pending Orders', 'dashboard-summary'); ?></h2>
     49                    <span class="card-value"><?php echo esc_html($total_pending); ?></span>
     50                </div>
     51            </a>
     52            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-completed')); ?>" class="card">
    5753                <i class="card-icon dashicons dashicons-admin-home"></i>
    58                 <h2><?php esc_html_e( 'Completed Orders', 'dashboard-summary' ); ?></h2>
    59                 <span class="card-value"><?php echo esc_html( $total_completed ); ?></span>
    60             </div>
    61             <div class="card">
     54                <div class="card-content">
     55                    <h2><?php esc_html_e('Completed Orders', 'dashboard-summary'); ?></h2>
     56                    <span class="card-value"><?php echo esc_html($total_completed); ?></span>
     57                </div>
     58            </a>
     59            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-on-hold')); ?>" class="card">
    6260                <i class="card-icon dashicons dashicons-hourglass"></i>
    63                 <h2><?php esc_html_e( 'On Hold Orders', 'dashboard-summary' ); ?></h2>
    64                 <span class="card-value"><?php echo esc_html( $total_on_hold ); ?></span>
    65             </div>
    66             <div class="card">
     61                <div class="card-content">
     62                    <h2><?php esc_html_e('On Hold Orders', 'dashboard-summary'); ?></h2>
     63                    <span class="card-value"><?php echo esc_html($total_on_hold); ?></span>
     64                </div>
     65            </a>
     66            <a href="<?php echo esc_url(admin_url('users.php?role=customer')); ?>" class="card">
    6767                <i class="card-icon dashicons dashicons-admin-users"></i>
    68                 <h2><?php esc_html_e( 'Total Customers', 'dashboard-summary' ); ?></h2>
    69                 <span class="card-value"><?php echo esc_html( $total_customers ); ?></span>
    70             </div>
    71             <div class="card">
     68                <div class="card-content">
     69                    <h2><?php esc_html_e('Total Customers', 'dashboard-summary'); ?></h2>
     70                    <span class="card-value"><?php echo esc_html($total_customers); ?></span>
     71                </div>
     72            </a>
     73            <a href="<?php echo esc_url(admin_url('edit.php?post_type=product')); ?>" class="card">
    7274                <i class="card-icon dashicons dashicons-cart"></i>
    73                 <h2><?php esc_html_e( 'Total Products', 'dashboard-summary' ); ?></h2>
    74                 <span class="card-value"><?php echo esc_html( $total_products ); ?></span>
    75             </div>
     75                <div class="card-content">
     76                    <h2><?php esc_html_e('Total Products', 'dashboard-summary'); ?></h2>
     77                    <span class="card-value"><?php echo esc_html($total_products); ?></span>
     78                </div>
     79            </a>
    7680        </div>
    7781    </div>
    78     <?php
     82<?php
    7983}
  • dashboard-summary/tags/1.1.0/readme.txt

    r3174721 r3383367  
    11=== Dashboard Summary ===
    2 Contributors: rejaulalomkhan, huzaifaalmesbah
     2Contributors: rejaulalomkhan
    33Tags: woocommerce, dashboard, summary, admin, stats
    44Requires at least: 5.6
    5 Tested up to: 6.6.2
     5Tested up to: 6.8
    66Requires PHP: 7.0
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A plugin to display WooCommerce stats on the WordPress admin dashboard.
     11Beautiful, colorful dashboard cards displaying WooCommerce and blog statistics with customizable gradient colors and responsive design.
    1212
    1313== Description ==
    1414
    15 Dashboard Summary is a WordPress plugin that integrates seamlessly with WooCommerce to provide a comprehensive overview of your shop's performance right from the admin dashboard. Monitor key metrics about your WooCommerce store and blog directly from your dashboard, helping you keep track of your business without navigating away from the main admin area.
     15Transform your WordPress admin dashboard with beautiful, modern gradient cards that display key metrics at a glance. Dashboard Summary provides a visually stunning way to monitor your WooCommerce store and blog performance without navigating away from your main admin area.
    1616
    17 = Key Features =
     17= Key Features =
    1818
    19 - **WooCommerce Summary**: Get a quick snapshot of your store's status including total orders, pending orders, completed orders, and orders on hold.
    20 - **Customer and Product Summary**: View the total number of customers and products available on your store.
    21 - **Blog Summary**: Monitor your blog's total posts, pages, comments, categories, tags, and users.
    22 - **Easy Settings**: Enable or disable WooCommerce and blog summaries through a simple settings page.
    23 - **Localization Support**: Fully localized to support different languages. Text domain used: 'dashboard-summary'.
     19**🎨 Beautiful Design**
     20- **Colorful Gradient Cards**: Modern gradient backgrounds with 6 unique color schemes
     21- **Customizable Colors**: Full control over card gradient colors via settings page
     22- **Professional Icons**: Clean, modern icons with glassmorphism effects
     23- **Smooth Animations**: Hover effects and smooth transitions for better UX
     24
     25**📊 WooCommerce Statistics**
     26- Total Orders with quick link to orders page
     27- Pending/Processing Orders tracking
     28- Completed Orders count
     29- On-Hold Orders monitoring
     30- Total Customers overview
     31- Product Count display
     32
     33**📝 Blog Statistics**
     34- Total Posts published
     35- Total Pages created
     36- Comments count
     37- Categories overview
     38- Tags summary
     39- User count
     40
     41**⚙️ Advanced Settings**
     42- Toggle WooCommerce and Blog summaries independently
     43- Professional toggle switches (iOS-style)
     44- Color picker for each card (start and end gradient colors)
     45- Live gradient preview
     46- Reverse color system: WooCommerce uses colors 1-6, Blog uses 6-1
     47
     48**📱 Fully Responsive**
     49- Desktop: 6 cards per row (large screens), 4 cards per row (medium screens)
     50- Tablet: 3 cards per row with optimized spacing
     51- Mobile: 2 cards per row with compact design
     52- Adaptive font sizes and padding for all screen sizes
     53
     54**🔗 Smart Navigation**
     55- All cards are clickable and link to relevant admin pages
     56- Direct access to orders, products, posts, pages, comments, etc.
     57- Seamless navigation without leaving dashboard context
     58
     59= 🎯 Perfect For =
     60
     61- WooCommerce store owners who want quick insights
     62- Blog administrators monitoring content metrics
     63- Agency owners managing multiple sites
     64- Anyone who wants a beautiful, functional dashboard
     65
     66= 🌐 Translation Ready =
     67
     68Fully localized with text domain 'dashboard-summary'. Ready for translation into any language.
    2469
    2570== Installation ==
    2671
    27 1. Upload the plugin files to the `/wp-content/plugins/dashboard-summary` directory, or install the plugin through the WordPress plugins screen directly.
    28 2. Activate the plugin through the 'Plugins' screen in WordPress.
    29 3. Use the **Dashboard Summary** settings page to configure plugin options.
    30 4. Ensure WooCommerce is active for optimal functionality.
     72= Automatic Installation =
     731. Go to WordPress admin panel → Plugins → Add New
     742. Search for "Dashboard Summary"
     753. Click "Install Now" and then "Activate"
     764. Navigate to Settings → Dashboard Summary to customize colors and options
     77
     78= Manual Installation =
     791. Download the plugin zip file
     802. Upload the plugin files to the `/wp-content/plugins/dashboard-summary` directory
     813. Activate the plugin through the 'Plugins' screen in WordPress
     824. Go to Settings → Dashboard Summary to configure
     83
     84= After Installation =
     851. Visit your WordPress dashboard to see the beautiful cards
     862. Customize card colors from Settings → Dashboard Summary
     873. Enable/disable WooCommerce or Blog summaries as needed
     884. (Optional) Ensure WooCommerce is active for store statistics
    3189
    3290== Frequently Asked Questions ==
     
    3492= Do I need WooCommerce for this plugin to work? =
    3593
    36 The WooCommerce summary feature requires WooCommerce to be installed and active. The blog summary feature works independently.
     94No! The Blog Summary works independently. WooCommerce Summary will only display if WooCommerce is installed and active.
    3795
    38 = How do I access the settings page? =
     96= How do I customize the card colors? =
    3997
    40 Navigate to 'Settings' -> 'Dashboard Summary' from your WordPress admin panel to access and configure plugin settings.
     98Go to Settings → Dashboard Summary. You'll find color pickers for each of the 6 cards. Choose start and end colors for beautiful gradients. Changes apply immediately after saving.
     99
     100= Can I change the order of colors? =
     101
     102Yes! The plugin uses a smart reverse color system. WooCommerce cards use colors 1-6 in normal order, while Blog cards use colors 6-1 in reverse order for visual variety.
     103
     104= Are the cards clickable? =
     105
     106Absolutely! Each card is a clickable link that takes you directly to the relevant admin page (orders, products, posts, comments, etc.).
     107
     108= Is it mobile responsive? =
     109
     110Yes! The plugin is fully responsive:
     111- Desktop: Up to 6 cards per row
     112- Tablet: 3 cards per row
     113- Mobile: 2 cards per row
     114All with optimized font sizes and spacing.
    41115
    42116= Can I disable certain features? =
    43117
    44 Yes, you can enable or disable WooCommerce summary and blog summary independently from the settings page.
     118Yes, use the toggle switches in Settings → Dashboard Summary to enable/disable WooCommerce and Blog summaries independently.
    45119
    46 = Is localization supported? =
     120= Will it slow down my dashboard? =
    47121
    48 Yes, the plugin is translation-ready with a text domain 'dashboard-summary'.
     122No! The plugin is lightweight and optimized for performance. Statistics are loaded efficiently only when viewing the dashboard.
     123
     124= Can I translate it to my language? =
     125
     126Yes! The plugin is translation-ready with text domain 'dashboard-summary'. Use any translation plugin like Loco Translate.
     127
     128= Does it work with my theme? =
     129
     130Yes! The plugin works with any WordPress theme as it's added to the admin dashboard area.
    49131
    50132== Screenshots ==
    51133
    52 1. Dashboard Summary Widget on Admin Dashboard showing detailed stats.
    53 2. Settings page to enable or disable specific summaries.
     1341. Beautiful colorful gradient cards on admin dashboard with WooCommerce statistics
     1352. Blog summary cards with modern design and clickable links
     1363. Professional settings page with toggle switches and color pickers
     1374. Responsive mobile view showing 2 cards per row
     1385. Tablet view with optimized 3-column layout
     1396. Color customization with live gradient preview
    54140
    55141== Changelog ==
    56142
    57 = 1.0.0 =
    58 * Initial release of the plugin.
    59 * Basic dashboard summaries for WooCommerce and blog features.
     143= 1.1.0 - October 23, 2025 =
     144* 🎨 Added beautiful gradient backgrounds for all cards
     145* 🌈 Customizable gradient colors via settings (6 color schemes)
     146* 🎯 Live gradient preview in settings page
     147* 🔄 Smart reverse color system (WooCommerce: 1-6, Blog: 6-1)
     148* 📱 Fully responsive design for all devices
     149* 🔗 Made all cards clickable with direct navigation
     150* 💅 Modern glassmorphism icon backgrounds
     151* ✨ Smooth hover animations and transitions
     152* 🎚️ iOS-style toggle switches in settings
     153* 📏 Added spacing between WooCommerce and Blog sections
     154* 🎨 Professional settings page redesign
     155* 🔧 Improved mobile layout (2 cards per row)
     156* 📊 Better card layout with icon on left, content on right
     157* ⚡ Performance optimizations
     158* 🐛 Bug fixes and stability improvements
     159
     160= 1.0.0 - Initial Release =
     161* Initial release of the plugin
     162* Basic dashboard summaries for WooCommerce and blog
     163* Simple checkbox settings
    60164
    61165== Upgrade Notice ==
    62166
     167= 1.1.0 =
     168Major visual upgrade! Beautiful gradient cards, customizable colors, fully responsive design, and professional settings page. Highly recommended upgrade for all users.
     169
    63170= 1.0.0 =
    64 Initial release. Upgrade to enjoy detailed WooCommerce and blog summaries directly from your dashboard.
     171Initial release. Enjoy detailed WooCommerce and blog summaries directly from your dashboard.
    65172
    66173== License ==
  • dashboard-summary/trunk/assets/css/dswp-style.css

    r3174717 r3383367  
    11.dashboard-summary {
    2     display: flex;
    3     flex-wrap: wrap;
    4     margin: 10px;
     2  display: flex;
     3  flex-wrap: wrap;
     4  margin: -5px;
     5  width: 100%;
    56}
    67
    78.dashboard-summary .card {
    8   background-color: #fff;
    9   border: 1px solid #ddd;
    10   border-radius: 10px;
     9  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     10  border: none;
     11  border-radius: 12px;
    1112  padding: 20px;
    12   margin: 10px;
    13   width: calc(16.66% - 40px);
    14   box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
     13  margin: 5px;
     14  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    1515  transition: all 0.3s ease-in-out;
    1616  display: flex;
     17  flex-direction: row;
    1718  align-items: center;
    18   justify-content: space-between;
    19   color: var(--text-color); /* use CSS variable for text color */
    20 }
    21 
    22 form div.error, .wrap .notice, .wrap div.error, .wrap div.updated {
    23     margin: 5px 0 0px !important;
     19  justify-content: flex-start;
     20  gap: 15px;
     21  color: #ffffff;
     22  text-decoration: none;
     23  flex: 1 1 calc(16.66% - 10px);
     24  box-sizing: border-box;
     25  position: relative;
     26  overflow: hidden;
     27}
     28
     29.dashboard-summary .card::before {
     30  content: '';
     31  position: absolute;
     32  top: 0;
     33  left: 0;
     34  right: 0;
     35  bottom: 0;
     36  background: rgba(255, 255, 255, 0.1);
     37  opacity: 0;
     38  transition: opacity 0.3s ease;
     39}
     40
     41.dashboard-summary .card:nth-child(1) {
     42  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
     43}
     44
     45.dashboard-summary .card:nth-child(2) {
     46  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
     47}
     48
     49.dashboard-summary .card:nth-child(3) {
     50  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
     51}
     52
     53.dashboard-summary .card:nth-child(4) {
     54  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
     55}
     56
     57.dashboard-summary .card:nth-child(5) {
     58  background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
     59}
     60
     61.dashboard-summary .card:nth-child(6) {
     62  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     63}
     64
     65.dashboard-summary a.card {
     66  text-decoration: none;
     67  color: #ffffff;
     68  cursor: pointer;
     69}
     70
     71.dashboard-summary a.card:hover::before {
     72  opacity: 1;
     73}
     74
     75form div.error,
     76.wrap .notice,
     77.wrap div.error,
     78.wrap div.updated {
     79  margin: 5px 0 0px !important;
    2480}
    2581
    2682.dashboard-summary .card-icon {
    27   font-size: 24px;
    28   margin-right: 10px;
    29   color: var(--icon-color); /* use CSS variable for icon color */
     83  font-size: 36px;
     84  margin: 0;
     85  color: rgba(255, 255, 255, 0.9);
     86  flex-shrink: 0;
     87  background: rgba(255, 255, 255, 0.2);
     88  width: 56px;
     89  height: 56px;
     90  display: flex;
     91  align-items: center;
     92  justify-content: center;
     93  border-radius: 12px;
     94  backdrop-filter: blur(10px);
     95}
     96
     97.dashboard-summary .card-content {
     98  display: flex;
     99  flex-direction: column;
     100  align-items: flex-start;
     101  gap: 5px;
     102  flex: 1;
     103}
     104
     105.dashboard-summary .card h2 {
     106  font-weight: 500;
     107  margin: 0;
     108  font-size: 13px;
     109  color: rgba(255, 255, 255, 0.9);
     110  text-transform: capitalize;
     111  letter-spacing: 0.3px;
    30112}
    31113
    32114.dashboard-summary .card-value {
    33   font-size: 24px;
     115  font-size: 28px;
     116  font-weight: 700;
     117  color: #ffffff;
     118  margin: 0;
     119  line-height: 1;
     120}
     121
     122.dashboard-summary .card:hover {
     123  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
     124  transform: translateY(-3px);
     125}
     126
     127.dashboard-summary .card p {
     128  font-size: 18px;
    34129  font-weight: bold;
    35130  color: var(--text-color); /* use CSS variable for text color */
    36131}
    37132
    38 .dashboard-summary .card:hover {
    39   background-color: #fff;
    40   border: 1px solid #ccc;
    41   box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    42   transform: translateY(-5px);
    43 }
    44 
    45 .dashboard-summary .card h2 {
    46     font-weight: bold;
    47     margin-top: 12px;
    48     color: var(--text-color); /* use CSS variable for text color */
    49 }
    50 
    51 .dashboard-summary .card p {
    52     font-size: 18px;
    53     font-weight: bold;
    54     color: var(--text-color); /* use CSS variable for text color */
    55 }
    56 
    57133/* Responsive design */
    58 @media only screen and (max-width: 768px) {
    59   .dashboard-summary .card {
    60         width: calc(50% - 40px);
    61     }
    62 }
    63 
     134
     135/* Desktop - Large screens (1200px and above) - 6 cards per row */
     136@media only screen and (min-width: 1200px) {
     137  .dashboard-summary .card {
     138    flex: 1 1 calc(16.66% - 10px);
     139    max-width: calc(16.66% - 10px);
     140  }
     141}
     142
     143/* Desktop - Medium screens (992px to 1199px) - 4 cards per row */
     144@media only screen and (min-width: 992px) and (max-width: 1199px) {
     145  .dashboard-summary .card {
     146    flex: 1 1 calc(25% - 10px);
     147    max-width: calc(25% - 10px);
     148  }
     149}
     150
     151/* Tablet - (768px to 991px) - 3 cards per row */
     152@media only screen and (min-width: 768px) and (max-width: 991px) {
     153  .dashboard-summary .card {
     154    flex: 1 1 calc(33.33% - 10px);
     155    max-width: calc(33.33% - 10px);
     156  }
     157}
     158
     159/* Mobile - Large (481px to 767px) - 2 cards per row */
     160@media only screen and (min-width: 481px) and (max-width: 767px) {
     161  .dashboard-summary {
     162    margin: -4px !important;
     163  }
     164 
     165  .dashboard-summary .card {
     166    flex: 0 1 calc(50% - 8px) !important;
     167    max-width: calc(50% - 8px) !important;
     168    min-width: calc(50% - 8px) !important;
     169    width: calc(50% - 8px) !important;
     170    margin: 4px !important;
     171    padding: 12px 10px !important;
     172    gap: 12px !important;
     173  }
     174 
     175  .dashboard-summary .card-icon {
     176    font-size: 28px !important;
     177    margin: 0 !important;
     178    width: 50px !important;
     179    height: 50px !important;
     180  }
     181 
     182  .dashboard-summary .card-content {
     183    gap: 4px !important;
     184  }
     185 
     186  .dashboard-summary .card h2 {
     187    font-size: 11px !important;
     188    margin: 0 !important;
     189  }
     190 
     191  .dashboard-summary .card-value {
     192    font-size: 24px !important;
     193    margin: 0 !important;
     194  }
     195}
     196
     197/* Mobile - Small (480px and below) - 2 cards per row */
    64198@media only screen and (max-width: 480px) {
    65   .dashboard-summary .card {
    66         width: calc(100% - 40px);
    67     }
    68 }
     199  .dashboard-summary {
     200    margin: -3px !important;
     201  }
     202 
     203  .dashboard-summary .card {
     204    flex: 0 1 calc(50% - 6px) !important;
     205    max-width: calc(50% - 6px) !important;
     206    min-width: calc(50% - 6px) !important;
     207    width: calc(50% - 6px) !important;
     208    margin: 3px !important;
     209    padding: 10px 8px !important;
     210    gap: 10px !important;
     211    border-radius: 10px !important;
     212  }
     213
     214  .dashboard-summary .card-icon {
     215    font-size: 24px !important;
     216    margin: 0 !important;
     217    width: 44px !important;
     218    height: 44px !important;
     219    border-radius: 10px !important;
     220  }
     221 
     222  .dashboard-summary .card-content {
     223    gap: 3px !important;
     224  }
     225
     226  .dashboard-summary .card h2 {
     227    font-size: 10px !important;
     228    margin: 0 !important;
     229  }
     230
     231  .dashboard-summary .card-value {
     232    font-size: 20px !important;
     233    margin: 0 !important;
     234  }
     235}
     236  }
     237}
  • dashboard-summary/trunk/dashboard-summary.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Plugin Name: Dashboard Summary
    4  * Description: Monitor key metrics about your WooCommerce store and blog directly from your dashboard, helping you keep track of your business without navigating away from the main admin area.
     5 * Description: Beautiful, colorful dashboard cards displaying WooCommerce and blog statistics with customizable gradient colors and responsive design.
    56 * Author: Rejaul Alom Khan
    67 * Author URI: https://profiles.wordpress.org/rejaulalomkhan
     
    89 * Requires at least: 5.6
    910 * Requires PHP: 7.0
    10  * Version: 1.0.0
     11 * Version: 1.1.0
    1112 * License: GPLv2 or later
    1213 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1617
    1718// Exit if accessed directly.
    18 if ( ! defined( 'ABSPATH' ) ) {
     19if (! defined('ABSPATH')) {
    1920    exit;
    2021}
    2122
    2223// Define plugin path, URL, and basename.
    23 define( 'DSWP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    24 define( 'DSWP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    25 define( 'DSWP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
     24define('DSWP_PLUGIN_PATH', plugin_dir_path(__FILE__));
     25define('DSWP_PLUGIN_URL', plugin_dir_url(__FILE__));
     26define('DSWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
    2627
    2728/**
    2829 * Enqueue styles.
    2930 */
    30 function dswp_enqueue_styles() {
     31function dswp_enqueue_styles()
     32{
    3133    wp_enqueue_style(
    3234        'dashboard-summary',
     
    3537        '1.0.0'
    3638    );
     39
     40    // Add dynamic inline CSS for custom colors
     41    $custom_css = dswp_get_dynamic_css();
     42    wp_add_inline_style('dashboard-summary', $custom_css);
    3743}
    3844
    39 add_action( 'admin_enqueue_scripts', 'dswp_enqueue_styles' );
     45add_action('admin_enqueue_scripts', 'dswp_enqueue_styles');
     46
     47/**
     48 * Generate dynamic CSS from saved color settings.
     49 *
     50 * @return string Dynamic CSS.
     51 */
     52function dswp_get_dynamic_css()
     53{
     54    $options = get_option('dswp_options');
     55
     56    // Default gradient colors
     57    $defaults = array(
     58        'card1' => array('start' => '#f093fb', 'end' => '#f5576c'),
     59        'card2' => array('start' => '#4facfe', 'end' => '#00f2fe'),
     60        'card3' => array('start' => '#43e97b', 'end' => '#38f9d7'),
     61        'card4' => array('start' => '#fa709a', 'end' => '#fee140'),
     62        'card5' => array('start' => '#30cfd0', 'end' => '#330867'),
     63        'card6' => array('start' => '#667eea', 'end' => '#764ba2'),
     64    );
     65
     66    $css = '';
     67
     68    // WooCommerce cards - Normal order (1-6)
     69    for ($i = 1; $i <= 6; $i++) {
     70        $card_id = 'card' . $i;
     71        $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     72        $end_color = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     73
     74        $css .= ".dashboard-summary-woocommerce .card:nth-child({$i}) { background: linear-gradient(135deg, {$start_color} 0%, {$end_color} 100%) !important; }\n";
     75    }
     76
     77    // Blog cards - Reverse order (6-1)
     78    for ($i = 1; $i <= 6; $i++) {
     79        $reverse_index = 7 - $i; // Reverse: 1->6, 2->5, 3->4, 4->3, 5->2, 6->1
     80        $card_id = 'card' . $reverse_index;
     81        $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     82        $end_color = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     83
     84        $css .= ".dashboard-summary-blog .card:nth-child({$i}) { background: linear-gradient(135deg, {$start_color} 0%, {$end_color} 100%) !important; }\n";
     85    }
     86
     87    // Add gap between sections on desktop
     88    $css .= "@media only screen and (min-width: 768px) {\n";
     89    $css .= "  .dswp-woocommerce-section { margin-bottom: 10px !important; }\n";
     90    $css .= "  .dswp-blog-section { margin-top: 10px !important; }\n";
     91    $css .= "}\n";
     92
     93    return $css;
     94}
    4095
    4196// Include required files.
     
    48103 * @return bool True if WooCommerce is active, false otherwise.
    49104 */
    50 function dswp_is_woocommerce_active() {
    51     return in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true );
     105function dswp_is_woocommerce_active()
     106{
     107    return in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')), true);
    52108}
    53109
    54110// Register activation hook.
    55 register_activation_hook( __FILE__, 'dswp_plugin_activate' );
     111register_activation_hook(__FILE__, 'dswp_plugin_activate');
    56112
    57113/**
    58114 * Activation function.
    59115 */
    60 function dswp_plugin_activate() {
    61     $options = get_option( 'dswp_options', array() );
     116function dswp_plugin_activate()
     117{
     118    $options = get_option('dswp_options', array());
    62119
    63120    // Enable blog summary by default.
     
    65122
    66123    // Check if WooCommerce is active, and if so, enable WooCommerce summary.
    67     if ( dswp_is_woocommerce_active() ) {
     124    if (dswp_is_woocommerce_active()) {
    68125        $options['enable_woocommerce'] = 1;
    69126    }
    70127
    71128    // Update the options in the database.
    72     update_option( 'dswp_options', $options );
     129    update_option('dswp_options', $options);
    73130}
    74131
     
    76133 * Initialize the plugin.
    77134 */
    78 function dswp_init_plugin() {
    79     $options = get_option( 'dswp_options' );
     135function dswp_init_plugin()
     136{
     137    $options = get_option('dswp_options');
    80138
    81     if ( isset( $options['enable_woocommerce'] ) && 1 === $options['enable_woocommerce'] && dswp_is_woocommerce_active() ) {
     139    if (isset($options['enable_woocommerce']) && 1 === $options['enable_woocommerce'] && dswp_is_woocommerce_active()) {
    82140        require_once DSWP_PLUGIN_PATH . 'includes/woocommerce-functions.php';
    83         add_action( 'wp_dashboard_setup', 'dswp_add_woocommerce_dashboard_widget' );
     141        add_action('admin_notices', 'dswp_woocommerce_summary_widget');
    84142    }
    85143
    86     if ( isset( $options['enable_blog'] ) && 1 === $options['enable_blog'] ) {
    87         add_action( 'wp_dashboard_setup', 'dswp_add_blog_dashboard_widget' );
     144    if (isset($options['enable_blog']) && 1 === $options['enable_blog']) {
     145        add_action('admin_notices', 'dswp_blog_summary_widget');
    88146    }
    89147}
    90148
    91 add_action( 'plugins_loaded', 'dswp_init_plugin' );
     149add_action('plugins_loaded', 'dswp_init_plugin');
    92150
    93151/**
    94152 * Register settings page.
    95153 */
    96 function dswp_register_settings_page() {
     154function dswp_register_settings_page()
     155{
    97156    add_options_page(
    98         __( 'Dashboard Summary Settings', 'dashboard-summary' ),
    99         __( 'Dashboard Summary', 'dashboard-summary' ),
     157        __('Dashboard Summary Settings', 'dashboard-summary'),
     158        __('Dashboard Summary', 'dashboard-summary'),
    100159        'manage_options',
    101160        'dashboard-summary-settings',
     
    104163}
    105164
    106 add_action( 'admin_menu', 'dswp_register_settings_page' );
     165add_action('admin_menu', 'dswp_register_settings_page');
  • dashboard-summary/trunk/includes/blog-functions.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Blog Functions
     
    910
    1011/**
    11  * Add Blog Summary Widget to Dashboard.
     12 * Display the Blog Summary content on dashboard.
    1213 */
    13 function dswp_add_blog_dashboard_widget() {
    14     $options = get_option( 'dswp_options' );
    15     if ( 1 === $options['enable_blog'] ) { // Use strict comparison and Yoda condition.
    16         wp_add_dashboard_widget(
    17             'dswp_blog_summary',
    18             __( 'Blog Summary', 'dashboard-summary' ),
    19             'dswp_blog_summary_widget'
    20         );
     14function dswp_blog_summary_widget()
     15{
     16    // Only show on dashboard page
     17    $screen = get_current_screen();
     18    if (! $screen || 'dashboard' !== $screen->id) {
     19        return;
    2120    }
    22 }
    2321
    24 add_action( 'wp_dashboard_setup', 'dswp_add_blog_dashboard_widget' );
    25 
    26 /**
    27  * Display the Blog Summary Widget content.
    28  */
    29 function dswp_blog_summary_widget() {
    3022    $total_posts      = wp_count_posts()->publish;
    31     $total_pages      = wp_count_posts( 'page' )->publish;
     23    $total_pages      = wp_count_posts('page')->publish;
    3224    $total_comments   = wp_count_comments()->total_comments;
    33     $total_categories = wp_count_terms( 'category' );
    34     $total_tags       = wp_count_terms( 'post_tag' );
     25    $total_categories = wp_count_terms('category');
     26    $total_tags       = wp_count_terms('post_tag');
    3527    $total_users      = count_users()['total_users'];
    3628
    3729    // Display data.
    38     ?>
    39     <div class="notice" style="background-color: #F0F0F1; border: none;">
    40         <div class="dashboard-summary">
    41             <div class="card">
     30?>
     31    <div class="notice dswp-blog-section" style="background-color: #F0F0F1; border: none;">
     32        <div class="dashboard-summary dashboard-summary-blog">
     33            <a href="<?php echo esc_url(admin_url('edit.php')); ?>" class="card">
    4234                <i class="card-icon dashicons dashicons-admin-post"></i>
    43                 <h2><?php esc_html_e( 'Total Posts', 'dashboard-summary' ); ?></h2>
    44                 <span class="card-value"><?php echo esc_html( $total_posts ); ?></span>
    45             </div>
    46             <div class="card">
     35                <div class="card-content">
     36                    <h2><?php esc_html_e('Total Posts', 'dashboard-summary'); ?></h2>
     37                    <span class="card-value"><?php echo esc_html($total_posts); ?></span>
     38                </div>
     39            </a>
     40            <a href="<?php echo esc_url(admin_url('edit.php?post_type=page')); ?>" class="card">
    4741                <i class="card-icon dashicons dashicons-admin-page"></i>
    48                 <h2><?php esc_html_e( 'Total Pages', 'dashboard-summary' ); ?></h2>
    49                 <span class="card-value"><?php echo esc_html( $total_pages ); ?></span>
    50             </div>
    51             <div class="card">
     42                <div class="card-content">
     43                    <h2><?php esc_html_e('Total Pages', 'dashboard-summary'); ?></h2>
     44                    <span class="card-value"><?php echo esc_html($total_pages); ?></span>
     45                </div>
     46            </a>
     47            <a href="<?php echo esc_url(admin_url('edit-comments.php')); ?>" class="card">
    5248                <i class="card-icon dashicons dashicons-admin-comments"></i>
    53                 <h2><?php esc_html_e( 'Total Comments', 'dashboard-summary' ); ?></h2>
    54                 <span class="card-value"><?php echo esc_html( $total_comments ); ?></span>
    55             </div>
    56             <div class="card">
     49                <div class="card-content">
     50                    <h2><?php esc_html_e('Total Comments', 'dashboard-summary'); ?></h2>
     51                    <span class="card-value"><?php echo esc_html($total_comments); ?></span>
     52                </div>
     53            </a>
     54            <a href="<?php echo esc_url(admin_url('edit-tags.php?taxonomy=category')); ?>" class="card">
    5755                <i class="card-icon dashicons dashicons-category"></i>
    58                 <h2><?php esc_html_e( 'Total Categories', 'dashboard-summary' ); ?></h2>
    59                 <span class="card-value"><?php echo esc_html( $total_categories ); ?></span>
    60             </div>
    61             <div class="card">
     56                <div class="card-content">
     57                    <h2><?php esc_html_e('Total Categories', 'dashboard-summary'); ?></h2>
     58                    <span class="card-value"><?php echo esc_html($total_categories); ?></span>
     59                </div>
     60            </a>
     61            <a href="<?php echo esc_url(admin_url('edit-tags.php?taxonomy=post_tag')); ?>" class="card">
    6262                <i class="card-icon dashicons dashicons-tag"></i>
    63                 <h2><?php esc_html_e( 'Total Tags', 'dashboard-summary' ); ?></h2>
    64                 <span class="card-value"><?php echo esc_html( $total_tags ); ?></span>
    65             </div>
    66             <div class="card">
     63                <div class="card-content">
     64                    <h2><?php esc_html_e('Total Tags', 'dashboard-summary'); ?></h2>
     65                    <span class="card-value"><?php echo esc_html($total_tags); ?></span>
     66                </div>
     67            </a>
     68            <a href="<?php echo esc_url(admin_url('users.php')); ?>" class="card">
    6769                <i class="card-icon dashicons dashicons-admin-users"></i>
    68                 <h2><?php esc_html_e( 'Total Users', 'dashboard-summary' ); ?></h2>
    69                 <span class="card-value"><?php echo esc_html( $total_users ); ?></span>
    70             </div>
     70                <div class="card-content">
     71                    <h2><?php esc_html_e('Total Users', 'dashboard-summary'); ?></h2>
     72                    <span class="card-value"><?php echo esc_html($total_users); ?></span>
     73                </div>
     74            </a>
    7175        </div>
    7276    </div>
    73     <?php
     77<?php
    7478}
  • dashboard-summary/trunk/includes/settings.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * Dashboard Summary Settings
     
    910
    1011// Exit if accessed directly.
    11 if ( ! defined( 'ABSPATH' ) ) {
     12if (! defined('ABSPATH')) {
    1213    exit;
    1314}
    1415
    1516/**
     17 * Enqueue settings page styles.
     18 */
     19function dswp_enqueue_settings_styles($hook)
     20{
     21    if ('settings_page_dashboard-summary-settings' !== $hook) {
     22        return;
     23    }
     24    wp_enqueue_style('wp-color-picker');
     25    wp_enqueue_script('wp-color-picker');
     26}
     27add_action('admin_enqueue_scripts', 'dswp_enqueue_settings_styles');
     28
     29/**
    1630 * Register the settings for the Dashboard Summary plugin.
    1731 */
    18 function dswp_register_settings() {
    19     add_filter( 'plugin_action_links_' . DSWP_PLUGIN_BASENAME, 'dswp_add_plugin_settings_link' );
    20     register_setting( 'dswp_options_group', 'dswp_options', 'dswp_options_validate' );
     32function dswp_register_settings()
     33{
     34    add_filter('plugin_action_links_' . DSWP_PLUGIN_BASENAME, 'dswp_add_plugin_settings_link');
     35    register_setting('dswp_options_group', 'dswp_options', 'dswp_options_validate');
     36
     37    // Display Settings Section
    2138    add_settings_section(
    22         'dswp_main_section',
    23         __( 'Main Settings', 'dashboard-summary' ),
    24         'dswp_main_section_text',
     39        'dswp_display_section',
     40        __('Display Settings', 'dashboard-summary'),
     41        'dswp_display_section_text',
    2542        'dashboard-summary-settings'
    2643    );
     44
    2745    add_settings_field(
    2846        'dswp_enable_woocommerce',
    29         __( 'Enable WooCommerce Summary', 'dashboard-summary' ),
     47        __('WooCommerce Summary', 'dashboard-summary'),
    3048        'dswp_enable_woocommerce_input',
    3149        'dashboard-summary-settings',
    32         'dswp_main_section'
    33     );
     50        'dswp_display_section'
     51    );
     52
    3453    add_settings_field(
    3554        'dswp_enable_blog',
    36         __( 'Enable Blog Summary', 'dashboard-summary' ),
     55        __('Blog Summary', 'dashboard-summary'),
    3756        'dswp_enable_blog_input',
    3857        'dashboard-summary-settings',
    39         'dswp_main_section'
    40     );
    41 }
    42 
    43 add_action( 'admin_init', 'dswp_register_settings' );
     58        'dswp_display_section'
     59    );
     60
     61    // Color Settings Section
     62    add_settings_section(
     63        'dswp_color_section',
     64        __('Card Color Customization', 'dashboard-summary'),
     65        'dswp_color_section_text',
     66        'dashboard-summary-settings'
     67    );
     68
     69    // Add color pickers for each card
     70    $cards = array(
     71        'card1' => __('Card 1 Color', 'dashboard-summary'),
     72        'card2' => __('Card 2 Color', 'dashboard-summary'),
     73        'card3' => __('Card 3 Color', 'dashboard-summary'),
     74        'card4' => __('Card 4 Color', 'dashboard-summary'),
     75        'card5' => __('Card 5 Color', 'dashboard-summary'),
     76        'card6' => __('Card 6 Color', 'dashboard-summary'),
     77    );
     78
     79    foreach ($cards as $card_id => $card_label) {
     80        add_settings_field(
     81            'dswp_' . $card_id . '_colors',
     82            $card_label,
     83            'dswp_card_color_input',
     84            'dashboard-summary-settings',
     85            'dswp_color_section',
     86            array('card_id' => $card_id)
     87        );
     88    }
     89}
     90
     91add_action('admin_init', 'dswp_register_settings');
    4492
    4593/**
     
    4997 * @return array Modified plugin action links.
    5098 */
    51 function dswp_add_plugin_settings_link( $links ) {
    52     $settings_link = '<a href="options-general.php?page=dashboard-summary-settings">' . esc_html__( 'Settings', 'dashboard-summary' ) . '</a>';
    53     array_push( $links, $settings_link );
     99function dswp_add_plugin_settings_link($links)
     100{
     101    $settings_link = '<a href="options-general.php?page=dashboard-summary-settings">' . esc_html__('Settings', 'dashboard-summary') . '</a>';
     102    array_push($links, $settings_link);
    54103    return $links;
    55104}
    56105
    57106/**
    58  * Main section text for settings page.
    59  */
    60 function dswp_main_section_text() {
    61     echo '<p>' . esc_html__( 'Enable or disable dashboard summaries.', 'dashboard-summary' ) . '</p>';
    62 }
    63 
    64 /**
    65  * WooCommerce summary input checkbox.
    66  */
    67 function dswp_enable_woocommerce_input() {
    68     $options = get_option( 'dswp_options' );
    69     $checked = isset( $options['enable_woocommerce'] ) ? $options['enable_woocommerce'] : 0;
    70     echo "<input type='checkbox' name='dswp_options[enable_woocommerce]' value='1' " . checked( 1, $checked, false ) . ' />';
    71 }
    72 
    73 /**
    74  * Blog summary input checkbox.
    75  */
    76 function dswp_enable_blog_input() {
    77     $options = get_option( 'dswp_options' );
    78     $checked = isset( $options['enable_blog'] ) ? $options['enable_blog'] : 0;
    79     echo "<input type='checkbox' name='dswp_options[enable_blog]' value='1' " . checked( 1, $checked, false ) . ' />';
     107 * Display section text for settings page.
     108 */
     109function dswp_display_section_text()
     110{
     111    echo '<p class="dswp-section-description">' . esc_html__('Toggle dashboard summary widgets on or off.', 'dashboard-summary') . '</p>';
     112}
     113
     114/**
     115 * Color section text for settings page.
     116 */
     117function dswp_color_section_text()
     118{
     119    echo '<p class="dswp-section-description">' . esc_html__('Customize gradient colors for each card. Set start and end colors for the gradient effect.', 'dashboard-summary') . '</p>';
     120}
     121
     122/**
     123 * WooCommerce summary toggle switch.
     124 */
     125function dswp_enable_woocommerce_input()
     126{
     127    $options = get_option('dswp_options');
     128    $checked = isset($options['enable_woocommerce']) ? $options['enable_woocommerce'] : 0;
     129?>
     130    <label class="dswp-toggle-switch">
     131        <input type="checkbox" name="dswp_options[enable_woocommerce]" value="1" <?php checked(1, $checked); ?> />
     132        <span class="dswp-toggle-slider"></span>
     133    </label>
     134    <p class="description"><?php esc_html_e('Display WooCommerce statistics on the dashboard.', 'dashboard-summary'); ?></p>
     135<?php
     136}
     137
     138/**
     139 * Blog summary toggle switch.
     140 */
     141function dswp_enable_blog_input()
     142{
     143    $options = get_option('dswp_options');
     144    $checked = isset($options['enable_blog']) ? $options['enable_blog'] : 0;
     145?>
     146    <label class="dswp-toggle-switch">
     147        <input type="checkbox" name="dswp_options[enable_blog]" value="1" <?php checked(1, $checked); ?> />
     148        <span class="dswp-toggle-slider"></span>
     149    </label>
     150    <p class="description"><?php esc_html_e('Display blog statistics on the dashboard.', 'dashboard-summary'); ?></p>
     151<?php
     152}
     153
     154/**
     155 * Card color picker inputs.
     156 *
     157 * @param array $args Arguments containing card_id.
     158 */
     159function dswp_card_color_input($args)
     160{
     161    $options = get_option('dswp_options');
     162    $card_id = $args['card_id'];
     163
     164    // Default gradient colors
     165    $defaults = array(
     166        'card1' => array('start' => '#f093fb', 'end' => '#f5576c'),
     167        'card2' => array('start' => '#4facfe', 'end' => '#00f2fe'),
     168        'card3' => array('start' => '#43e97b', 'end' => '#38f9d7'),
     169        'card4' => array('start' => '#fa709a', 'end' => '#fee140'),
     170        'card5' => array('start' => '#30cfd0', 'end' => '#330867'),
     171        'card6' => array('start' => '#667eea', 'end' => '#764ba2'),
     172    );
     173
     174    $start_color = isset($options[$card_id . '_start']) ? $options[$card_id . '_start'] : $defaults[$card_id]['start'];
     175    $end_color   = isset($options[$card_id . '_end']) ? $options[$card_id . '_end'] : $defaults[$card_id]['end'];
     176?>
     177    <div class="dswp-color-picker-group">
     178        <div class="dswp-color-input">
     179            <label><?php esc_html_e('Start Color', 'dashboard-summary'); ?></label>
     180            <input type="text" name="dswp_options[<?php echo esc_attr($card_id); ?>_start]" value="<?php echo esc_attr($start_color); ?>" class="dswp-color-picker" />
     181        </div>
     182        <div class="dswp-color-input">
     183            <label><?php esc_html_e('End Color', 'dashboard-summary'); ?></label>
     184            <input type="text" name="dswp_options[<?php echo esc_attr($card_id); ?>_end]" value="<?php echo esc_attr($end_color); ?>" class="dswp-color-picker" />
     185        </div>
     186        <div class="dswp-gradient-preview" style="background: linear-gradient(135deg, <?php echo esc_attr($start_color); ?> 0%, <?php echo esc_attr($end_color); ?> 100%);"></div>
     187    </div>
     188<?php
    80189}
    81190
     
    86195 * @return array The sanitized input values.
    87196 */
    88 function dswp_options_validate( $input ) {
     197function dswp_options_validate($input)
     198{
    89199    $new_input                       = array();
    90     $new_input['enable_woocommerce'] = isset( $input['enable_woocommerce'] ) ? 1 : 0;
    91     $new_input['enable_blog']        = isset( $input['enable_blog'] ) ? 1 : 0;
     200    $new_input['enable_woocommerce'] = isset($input['enable_woocommerce']) ? 1 : 0;
     201    $new_input['enable_blog']        = isset($input['enable_blog']) ? 1 : 0;
     202
     203    // Sanitize color inputs
     204    $cards = array('card1', 'card2', 'card3', 'card4', 'card5', 'card6');
     205    foreach ($cards as $card_id) {
     206        if (isset($input[$card_id . '_start'])) {
     207            $new_input[$card_id . '_start'] = sanitize_hex_color($input[$card_id . '_start']);
     208        }
     209        if (isset($input[$card_id . '_end'])) {
     210            $new_input[$card_id . '_end'] = sanitize_hex_color($input[$card_id . '_end']);
     211        }
     212    }
     213
    92214    return $new_input;
    93215}
     
    96218 * Render the settings page for the Dashboard Summary.
    97219 */
    98 function dswp_render_settings_page() {
    99     ?>
    100     <div class="wrap">
    101         <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
    102         <form method="post" action="options.php">
    103             <?php
    104             settings_fields( 'dswp_options_group' );
    105             do_settings_sections( 'dashboard-summary-settings' );
    106             submit_button();
    107             ?>
     220function dswp_render_settings_page()
     221{
     222?>
     223    <div class="wrap dswp-settings-wrap">
     224        <div class="dswp-settings-header">
     225            <h1>
     226                <span class="dashicons dashicons-chart-area"></span>
     227                <?php echo esc_html(get_admin_page_title()); ?>
     228            </h1>
     229            <p class="dswp-subtitle"><?php esc_html_e('Customize your dashboard summary cards and display options.', 'dashboard-summary'); ?></p>
     230        </div>
     231
     232        <form method="post" action="options.php" class="dswp-settings-form">
     233            <?php settings_fields('dswp_options_group'); ?>
     234
     235            <div class="dswp-notice-info">
     236                <span class="dashicons dashicons-info"></span>
     237                <span><?php esc_html_e('Changes will take effect immediately after saving. WooCommerce cards use colors 1-6, Blog cards use colors in reverse order (6-1).', 'dashboard-summary'); ?></span>
     238            </div>
     239
     240            <?php do_settings_sections('dashboard-summary-settings'); ?>
     241
     242            <div class="dswp-submit-wrapper">
     243                <?php submit_button(__('Save Settings', 'dashboard-summary'), 'primary large', 'submit', false); ?>
     244            </div>
    108245        </form>
    109246    </div>
    110     <?php
    111 }
     247
     248    <style>
     249        /* Modern Settings Page Styles */
     250        .dswp-settings-wrap {
     251            max-width: 1200px;
     252            margin: 20px 0;
     253        }
     254
     255        .dswp-settings-header {
     256            background: #ffffff;
     257            border-left: 4px solid #667eea;
     258            padding: 20px 30px;
     259            border-radius: 8px;
     260            margin-bottom: 25px;
     261            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
     262        }
     263
     264        .dswp-settings-header h1 {
     265            color: #333;
     266            font-size: 26px;
     267            margin: 0 0 8px 0;
     268            display: flex;
     269            align-items: center;
     270            gap: 12px;
     271        }
     272
     273        .dswp-settings-header h1 .dashicons {
     274            font-size: 28px;
     275            width: 28px;
     276            height: 28px;
     277            color: #667eea;
     278        }
     279
     280        .dswp-subtitle {
     281            margin: 0;
     282            color: #666;
     283            font-size: 14px;
     284        }
     285
     286        /* Notice Info Box */
     287        .dswp-notice-info {
     288            background: #e7f3ff;
     289            border-left: 4px solid #2196f3;
     290            padding: 15px 20px;
     291            margin: 20px 0;
     292            border-radius: 4px;
     293            display: flex;
     294            align-items: flex-start;
     295            gap: 12px;
     296        }
     297
     298        .dswp-notice-info .dashicons {
     299            color: #2196f3;
     300            font-size: 20px;
     301            width: 20px;
     302            height: 20px;
     303            flex-shrink: 0;
     304            margin-top: 2px;
     305        }
     306
     307        .dswp-notice-info span:not(.dashicons) {
     308            color: #0c5ba8;
     309            font-size: 14px;
     310            line-height: 1.6;
     311        }
     312
     313        .dswp-settings-form h2 {
     314            background: #f8f9fa;
     315            padding: 15px 20px;
     316            border-left: 4px solid #667eea;
     317            margin: 30px 0 20px 0;
     318            font-size: 18px;
     319            border-radius: 4px;
     320        }
     321
     322        .dswp-section-description {
     323            color: #666;
     324            font-size: 14px;
     325            margin: -10px 0 20px 0;
     326        }
     327
     328        /* Toggle Switch Styles */
     329        .dswp-toggle-switch {
     330            position: relative;
     331            display: inline-block;
     332            width: 54px;
     333            height: 28px;
     334            margin-right: 10px;
     335        }
     336
     337        .dswp-toggle-switch input {
     338            opacity: 0;
     339            width: 0;
     340            height: 0;
     341        }
     342
     343        .dswp-toggle-slider {
     344            position: absolute;
     345            cursor: pointer;
     346            top: 0;
     347            left: 0;
     348            right: 0;
     349            bottom: 0;
     350            background-color: #ccc;
     351            transition: 0.3s;
     352            border-radius: 28px;
     353        }
     354
     355        .dswp-toggle-slider:before {
     356            position: absolute;
     357            content: "";
     358            height: 20px;
     359            width: 20px;
     360            left: 4px;
     361            bottom: 4px;
     362            background-color: white;
     363            transition: 0.3s;
     364            border-radius: 50%;
     365        }
     366
     367        .dswp-toggle-switch input:checked+.dswp-toggle-slider {
     368            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     369        }
     370
     371        .dswp-toggle-switch input:checked+.dswp-toggle-slider:before {
     372            transform: translateX(26px);
     373        }
     374
     375        .dswp-toggle-switch input:focus+.dswp-toggle-slider {
     376            box-shadow: 0 0 1px #667eea;
     377        }
     378
     379        /* Color Picker Group Styles */
     380        .dswp-color-picker-group {
     381            display: flex;
     382            gap: 20px;
     383            align-items: flex-start;
     384            flex-wrap: wrap;
     385        }
     386
     387        .dswp-color-input {
     388            display: flex;
     389            flex-direction: column;
     390            gap: 8px;
     391        }
     392
     393        .dswp-color-input label {
     394            font-weight: 500;
     395            font-size: 13px;
     396            color: #555;
     397        }
     398
     399        .dswp-color-picker {
     400            width: 100px !important;
     401        }
     402
     403        .dswp-gradient-preview {
     404            width: 150px;
     405            height: 40px;
     406            border-radius: 8px;
     407            border: 2px solid #e0e0e0;
     408            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
     409        }
     410
     411        .form-table th {
     412            width: 220px;
     413            font-weight: 600;
     414            color: #333;
     415        }
     416
     417        .form-table td {
     418            padding: 20px 10px;
     419        }
     420
     421        .form-table td .description {
     422            margin-top: 8px;
     423            font-style: italic;
     424            color: #666;
     425        }
     426
     427        /* Submit Button */
     428        .dswp-submit-wrapper {
     429            margin-top: 30px;
     430            padding-top: 20px;
     431            border-top: 1px solid #e0e0e0;
     432        }
     433
     434        .dswp-submit-wrapper .button-primary {
     435            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     436            border: none;
     437            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
     438            text-shadow: none;
     439            padding: 8px 30px;
     440            height: auto;
     441            font-size: 15px;
     442            transition: all 0.3s ease;
     443        }
     444
     445        .dswp-submit-wrapper .button-primary:hover {
     446            background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
     447            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
     448            transform: translateY(-2px);
     449        }
     450
     451        .dswp-submit-wrapper .button-primary:active {
     452            transform: translateY(0);
     453        }
     454    </style>
     455
     456    <script>
     457        jQuery(document).ready(function($) {
     458            // Initialize color pickers
     459            $('.dswp-color-picker').wpColorPicker({
     460                change: function(event, ui) {
     461                    var element = $(this).closest('.dswp-color-picker-group');
     462                    var startColor = element.find('input[name*="_start"]').val();
     463                    var endColor = element.find('input[name*="_end"]').val();
     464                    element.find('.dswp-gradient-preview').css('background', 'linear-gradient(135deg, ' + startColor + ' 0%, ' + endColor + ' 100%)');
     465                }
     466            });
     467        });
     468    </script>
     469<?php
     470}
  • dashboard-summary/trunk/includes/woocommerce-functions.php

    r3174717 r3383367  
    11<?php
     2
    23/**
    34 * WooCommerce Summary Widget
     
    910
    1011/**
    11  * Adds the WooCommerce Summary Widget to the dashboard.
     12 * Displays the WooCommerce Summary content on dashboard.
    1213 */
    13 function dswp_add_woocommerce_dashboard_widget() {
    14     $options = get_option( 'dswp_options' );
    15     if ( isset( $options['enable_woocommerce'] ) && 1 === $options['enable_woocommerce'] ) { // Use strict comparison and Yoda condition.
    16         wp_add_dashboard_widget(
    17             'dswp_woocommerce_summary',
    18             __( 'WooCommerce Summary', 'dashboard-summary' ),
    19             'dswp_woocommerce_summary_widget'
    20         );
     14function dswp_woocommerce_summary_widget()
     15{
     16    // Only show on dashboard page
     17    $screen = get_current_screen();
     18    if (! $screen || 'dashboard' !== $screen->id) {
     19        return;
    2120    }
    22 }
    2321
    24 add_action( 'wp_dashboard_setup', 'dswp_add_woocommerce_dashboard_widget' );
    25 
    26 /**
    27  * Displays the content of the WooCommerce Summary Widget.
    28  */
    29 function dswp_woocommerce_summary_widget() {
    3022    // Get WooCommerce data.
    31     $orders           = wc_get_orders( array( 'status' => 'any' ) );
    32     $total_orders     = count( $orders );
    33     $pending_orders   = wc_get_orders( array( 'status' => 'processing' ) );
    34     $total_pending    = count( $pending_orders );
    35     $on_hold_orders   = wc_get_orders( array( 'status' => 'on-hold' ) );
    36     $total_on_hold    = count( $on_hold_orders );
    37     $completed_orders = wc_get_orders( array( 'status' => 'completed' ) );
    38     $total_completed  = count( $completed_orders );
    39     $total_customers  = count( get_users( array( 'role' => 'customer' ) ) );
    40     $total_products   = wp_count_posts( 'product' )->publish;
     23    $orders           = wc_get_orders(array('status' => 'any'));
     24    $total_orders     = count($orders);
     25    $pending_orders   = wc_get_orders(array('status' => 'processing'));
     26    $total_pending    = count($pending_orders);
     27    $on_hold_orders   = wc_get_orders(array('status' => 'on-hold'));
     28    $total_on_hold    = count($on_hold_orders);
     29    $completed_orders = wc_get_orders(array('status' => 'completed'));
     30    $total_completed  = count($completed_orders);
     31    $total_customers  = count(get_users(array('role' => 'customer')));
     32    $total_products   = wp_count_posts('product')->publish;
    4133
    4234    // Display data.
    43     ?>
    44     <div class="notice" style="background-color: #F0F0F1; border: none;">
    45         <div class="dashboard-summary">
    46             <div class="card">
     35?>
     36    <div class="notice dswp-woocommerce-section" style="background-color: #F0F0F1; border: none;">
     37        <div class="dashboard-summary dashboard-summary-woocommerce">
     38            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order')); ?>" class="card">
    4739                <i class="card-icon dashicons dashicons-chart-bar"></i>
    48                 <h2><?php esc_html_e( 'Total Orders', 'dashboard-summary' ); ?></h2>
    49                 <span class="card-value"><?php echo esc_html( $total_orders ); ?></span>
    50             </div>
    51             <div class="card">
     40                <div class="card-content">
     41                    <h2><?php esc_html_e('Total Orders', 'dashboard-summary'); ?></h2>
     42                    <span class="card-value"><?php echo esc_html($total_orders); ?></span>
     43                </div>
     44            </a>
     45            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-processing')); ?>" class="card">
    5246                <i class="card-icon dashicons dashicons-clock"></i>
    53                 <h2><?php esc_html_e( 'Pending Orders', 'dashboard-summary' ); ?></h2>
    54                 <span class="card-value"><?php echo esc_html( $total_pending ); ?></span>
    55             </div>
    56             <div class="card">
     47                <div class="card-content">
     48                    <h2><?php esc_html_e('Pending Orders', 'dashboard-summary'); ?></h2>
     49                    <span class="card-value"><?php echo esc_html($total_pending); ?></span>
     50                </div>
     51            </a>
     52            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-completed')); ?>" class="card">
    5753                <i class="card-icon dashicons dashicons-admin-home"></i>
    58                 <h2><?php esc_html_e( 'Completed Orders', 'dashboard-summary' ); ?></h2>
    59                 <span class="card-value"><?php echo esc_html( $total_completed ); ?></span>
    60             </div>
    61             <div class="card">
     54                <div class="card-content">
     55                    <h2><?php esc_html_e('Completed Orders', 'dashboard-summary'); ?></h2>
     56                    <span class="card-value"><?php echo esc_html($total_completed); ?></span>
     57                </div>
     58            </a>
     59            <a href="<?php echo esc_url(admin_url('edit.php?post_type=shop_order&post_status=wc-on-hold')); ?>" class="card">
    6260                <i class="card-icon dashicons dashicons-hourglass"></i>
    63                 <h2><?php esc_html_e( 'On Hold Orders', 'dashboard-summary' ); ?></h2>
    64                 <span class="card-value"><?php echo esc_html( $total_on_hold ); ?></span>
    65             </div>
    66             <div class="card">
     61                <div class="card-content">
     62                    <h2><?php esc_html_e('On Hold Orders', 'dashboard-summary'); ?></h2>
     63                    <span class="card-value"><?php echo esc_html($total_on_hold); ?></span>
     64                </div>
     65            </a>
     66            <a href="<?php echo esc_url(admin_url('users.php?role=customer')); ?>" class="card">
    6767                <i class="card-icon dashicons dashicons-admin-users"></i>
    68                 <h2><?php esc_html_e( 'Total Customers', 'dashboard-summary' ); ?></h2>
    69                 <span class="card-value"><?php echo esc_html( $total_customers ); ?></span>
    70             </div>
    71             <div class="card">
     68                <div class="card-content">
     69                    <h2><?php esc_html_e('Total Customers', 'dashboard-summary'); ?></h2>
     70                    <span class="card-value"><?php echo esc_html($total_customers); ?></span>
     71                </div>
     72            </a>
     73            <a href="<?php echo esc_url(admin_url('edit.php?post_type=product')); ?>" class="card">
    7274                <i class="card-icon dashicons dashicons-cart"></i>
    73                 <h2><?php esc_html_e( 'Total Products', 'dashboard-summary' ); ?></h2>
    74                 <span class="card-value"><?php echo esc_html( $total_products ); ?></span>
    75             </div>
     75                <div class="card-content">
     76                    <h2><?php esc_html_e('Total Products', 'dashboard-summary'); ?></h2>
     77                    <span class="card-value"><?php echo esc_html($total_products); ?></span>
     78                </div>
     79            </a>
    7680        </div>
    7781    </div>
    78     <?php
     82<?php
    7983}
  • dashboard-summary/trunk/readme.txt

    r3174721 r3383367  
    11=== Dashboard Summary ===
    2 Contributors: rejaulalomkhan, huzaifaalmesbah
     2Contributors: rejaulalomkhan
    33Tags: woocommerce, dashboard, summary, admin, stats
    44Requires at least: 5.6
    5 Tested up to: 6.6.2
     5Tested up to: 6.8
    66Requires PHP: 7.0
    7 Stable tag: 1.0.0
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A plugin to display WooCommerce stats on the WordPress admin dashboard.
     11Beautiful, colorful dashboard cards displaying WooCommerce and blog statistics with customizable gradient colors and responsive design.
    1212
    1313== Description ==
    1414
    15 Dashboard Summary is a WordPress plugin that integrates seamlessly with WooCommerce to provide a comprehensive overview of your shop's performance right from the admin dashboard. Monitor key metrics about your WooCommerce store and blog directly from your dashboard, helping you keep track of your business without navigating away from the main admin area.
     15Transform your WordPress admin dashboard with beautiful, modern gradient cards that display key metrics at a glance. Dashboard Summary provides a visually stunning way to monitor your WooCommerce store and blog performance without navigating away from your main admin area.
    1616
    17 = Key Features =
     17= Key Features =
    1818
    19 - **WooCommerce Summary**: Get a quick snapshot of your store's status including total orders, pending orders, completed orders, and orders on hold.
    20 - **Customer and Product Summary**: View the total number of customers and products available on your store.
    21 - **Blog Summary**: Monitor your blog's total posts, pages, comments, categories, tags, and users.
    22 - **Easy Settings**: Enable or disable WooCommerce and blog summaries through a simple settings page.
    23 - **Localization Support**: Fully localized to support different languages. Text domain used: 'dashboard-summary'.
     19**🎨 Beautiful Design**
     20- **Colorful Gradient Cards**: Modern gradient backgrounds with 6 unique color schemes
     21- **Customizable Colors**: Full control over card gradient colors via settings page
     22- **Professional Icons**: Clean, modern icons with glassmorphism effects
     23- **Smooth Animations**: Hover effects and smooth transitions for better UX
     24
     25**📊 WooCommerce Statistics**
     26- Total Orders with quick link to orders page
     27- Pending/Processing Orders tracking
     28- Completed Orders count
     29- On-Hold Orders monitoring
     30- Total Customers overview
     31- Product Count display
     32
     33**📝 Blog Statistics**
     34- Total Posts published
     35- Total Pages created
     36- Comments count
     37- Categories overview
     38- Tags summary
     39- User count
     40
     41**⚙️ Advanced Settings**
     42- Toggle WooCommerce and Blog summaries independently
     43- Professional toggle switches (iOS-style)
     44- Color picker for each card (start and end gradient colors)
     45- Live gradient preview
     46- Reverse color system: WooCommerce uses colors 1-6, Blog uses 6-1
     47
     48**📱 Fully Responsive**
     49- Desktop: 6 cards per row (large screens), 4 cards per row (medium screens)
     50- Tablet: 3 cards per row with optimized spacing
     51- Mobile: 2 cards per row with compact design
     52- Adaptive font sizes and padding for all screen sizes
     53
     54**🔗 Smart Navigation**
     55- All cards are clickable and link to relevant admin pages
     56- Direct access to orders, products, posts, pages, comments, etc.
     57- Seamless navigation without leaving dashboard context
     58
     59= 🎯 Perfect For =
     60
     61- WooCommerce store owners who want quick insights
     62- Blog administrators monitoring content metrics
     63- Agency owners managing multiple sites
     64- Anyone who wants a beautiful, functional dashboard
     65
     66= 🌐 Translation Ready =
     67
     68Fully localized with text domain 'dashboard-summary'. Ready for translation into any language.
    2469
    2570== Installation ==
    2671
    27 1. Upload the plugin files to the `/wp-content/plugins/dashboard-summary` directory, or install the plugin through the WordPress plugins screen directly.
    28 2. Activate the plugin through the 'Plugins' screen in WordPress.
    29 3. Use the **Dashboard Summary** settings page to configure plugin options.
    30 4. Ensure WooCommerce is active for optimal functionality.
     72= Automatic Installation =
     731. Go to WordPress admin panel → Plugins → Add New
     742. Search for "Dashboard Summary"
     753. Click "Install Now" and then "Activate"
     764. Navigate to Settings → Dashboard Summary to customize colors and options
     77
     78= Manual Installation =
     791. Download the plugin zip file
     802. Upload the plugin files to the `/wp-content/plugins/dashboard-summary` directory
     813. Activate the plugin through the 'Plugins' screen in WordPress
     824. Go to Settings → Dashboard Summary to configure
     83
     84= After Installation =
     851. Visit your WordPress dashboard to see the beautiful cards
     862. Customize card colors from Settings → Dashboard Summary
     873. Enable/disable WooCommerce or Blog summaries as needed
     884. (Optional) Ensure WooCommerce is active for store statistics
    3189
    3290== Frequently Asked Questions ==
     
    3492= Do I need WooCommerce for this plugin to work? =
    3593
    36 The WooCommerce summary feature requires WooCommerce to be installed and active. The blog summary feature works independently.
     94No! The Blog Summary works independently. WooCommerce Summary will only display if WooCommerce is installed and active.
    3795
    38 = How do I access the settings page? =
     96= How do I customize the card colors? =
    3997
    40 Navigate to 'Settings' -> 'Dashboard Summary' from your WordPress admin panel to access and configure plugin settings.
     98Go to Settings → Dashboard Summary. You'll find color pickers for each of the 6 cards. Choose start and end colors for beautiful gradients. Changes apply immediately after saving.
     99
     100= Can I change the order of colors? =
     101
     102Yes! The plugin uses a smart reverse color system. WooCommerce cards use colors 1-6 in normal order, while Blog cards use colors 6-1 in reverse order for visual variety.
     103
     104= Are the cards clickable? =
     105
     106Absolutely! Each card is a clickable link that takes you directly to the relevant admin page (orders, products, posts, comments, etc.).
     107
     108= Is it mobile responsive? =
     109
     110Yes! The plugin is fully responsive:
     111- Desktop: Up to 6 cards per row
     112- Tablet: 3 cards per row
     113- Mobile: 2 cards per row
     114All with optimized font sizes and spacing.
    41115
    42116= Can I disable certain features? =
    43117
    44 Yes, you can enable or disable WooCommerce summary and blog summary independently from the settings page.
     118Yes, use the toggle switches in Settings → Dashboard Summary to enable/disable WooCommerce and Blog summaries independently.
    45119
    46 = Is localization supported? =
     120= Will it slow down my dashboard? =
    47121
    48 Yes, the plugin is translation-ready with a text domain 'dashboard-summary'.
     122No! The plugin is lightweight and optimized for performance. Statistics are loaded efficiently only when viewing the dashboard.
     123
     124= Can I translate it to my language? =
     125
     126Yes! The plugin is translation-ready with text domain 'dashboard-summary'. Use any translation plugin like Loco Translate.
     127
     128= Does it work with my theme? =
     129
     130Yes! The plugin works with any WordPress theme as it's added to the admin dashboard area.
    49131
    50132== Screenshots ==
    51133
    52 1. Dashboard Summary Widget on Admin Dashboard showing detailed stats.
    53 2. Settings page to enable or disable specific summaries.
     1341. Beautiful colorful gradient cards on admin dashboard with WooCommerce statistics
     1352. Blog summary cards with modern design and clickable links
     1363. Professional settings page with toggle switches and color pickers
     1374. Responsive mobile view showing 2 cards per row
     1385. Tablet view with optimized 3-column layout
     1396. Color customization with live gradient preview
    54140
    55141== Changelog ==
    56142
    57 = 1.0.0 =
    58 * Initial release of the plugin.
    59 * Basic dashboard summaries for WooCommerce and blog features.
     143= 1.1.0 - October 23, 2025 =
     144* 🎨 Added beautiful gradient backgrounds for all cards
     145* 🌈 Customizable gradient colors via settings (6 color schemes)
     146* 🎯 Live gradient preview in settings page
     147* 🔄 Smart reverse color system (WooCommerce: 1-6, Blog: 6-1)
     148* 📱 Fully responsive design for all devices
     149* 🔗 Made all cards clickable with direct navigation
     150* 💅 Modern glassmorphism icon backgrounds
     151* ✨ Smooth hover animations and transitions
     152* 🎚️ iOS-style toggle switches in settings
     153* 📏 Added spacing between WooCommerce and Blog sections
     154* 🎨 Professional settings page redesign
     155* 🔧 Improved mobile layout (2 cards per row)
     156* 📊 Better card layout with icon on left, content on right
     157* ⚡ Performance optimizations
     158* 🐛 Bug fixes and stability improvements
     159
     160= 1.0.0 - Initial Release =
     161* Initial release of the plugin
     162* Basic dashboard summaries for WooCommerce and blog
     163* Simple checkbox settings
    60164
    61165== Upgrade Notice ==
    62166
     167= 1.1.0 =
     168Major visual upgrade! Beautiful gradient cards, customizable colors, fully responsive design, and professional settings page. Highly recommended upgrade for all users.
     169
    63170= 1.0.0 =
    64 Initial release. Upgrade to enjoy detailed WooCommerce and blog summaries directly from your dashboard.
     171Initial release. Enjoy detailed WooCommerce and blog summaries directly from your dashboard.
    65172
    66173== License ==
Note: See TracChangeset for help on using the changeset viewer.