-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublished-counts.php
More file actions
118 lines (91 loc) · 4.72 KB
/
published-counts.php
File metadata and controls
118 lines (91 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Plugin Name: Published Counts (beta)
* Description: Adds a Dashboard Widget and Report Page to compare the number of published posts by Year, Month, and Category.
* Version: 1.0.beta4
* Requires at least: 6.7
* Requires PHP: 8.0
* Author: Daniel Bishop
* Author URI: https://beachfleischman.com/
* License: GPL2
* Text Domain: pubcounts
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
define( 'PUBCOUNTS_VERSION', '1.0.beta4' );
if ( ! defined( 'AUTHOR_CO_LEGAL_NAME' ) ) {
define( 'AUTHOR_CO_LEGAL_NAME', 'BeachFleischman PLLC' );
}
function pubcounts_is_local_environment() {
$env = wp_get_environment_type();
return ( defined('WP_ENVIRONMENT_TYPE') && $env === 'local' );
}
function pubcounts_get_icon_markup( $name ) {
return file_get_contents( __DIR__ . "/assets/$name.svg" );
}
// activation hook
function pubcounts_activate() {
// set custom settings...
}
register_activation_hook( __FILE__, 'pubcounts_activate' );
// deactivation hook
function pubcounts_deactivate() {
delete_option( 'pubcounts_options' );
}
register_deactivation_hook( __FILE__, 'pubcounts_deactivate' );
$now = ( new DateTime( 'now', new DateTimeZone( get_option( 'timezone_string' ) ) ) )->format( 'Y-m-d H:i:s' );
// Get the current month and year
$current_year = date('Y');
$years = range(date('Y'), date('Y') - 4); // Get last 5 years
$current_month = date('F');
$current_month_num = date('m');
$current_month_and_year = date('F Y');
$prev_month = date('F Y', strtotime('last month'));
$plugin_footer_text = 'Plugin version: <strong>' . PUBCOUNTS_VERSION . '</strong> provided by ' . AUTHOR_CO_LEGAL_NAME . '.<br />The BeachFleischman logo, BEACHFLEISCHMAN, and COLLABORATE FORWARD are all registered U.S. trademarks of ' . AUTHOR_CO_LEGAL_NAME . '. ©' . date('Y') . ' <a href="https://beachfleischman.com/" target="_blank">' . AUTHOR_CO_LEGAL_NAME . '</a>. All rights reserved.';
$plugin_footer_text_long = 'Counts are current as of <time datetime="' . $now . '">' . $now . '</time>. Plugin version: <strong>' . PUBCOUNTS_VERSION . '</strong> provided by ' . AUTHOR_CO_LEGAL_NAME . '.<br />The BeachFleischman logo, BEACHFLEISCHMAN, and COLLABORATE FORWARD are all registered U.S. trademarks of ' . AUTHOR_CO_LEGAL_NAME . '. ©' . date('Y') . ' <a href="https://beachfleischman.com/" target="_blank">' . AUTHOR_CO_LEGAL_NAME . '</a>. All rights reserved.';
function pubcounts_get_monthly_theme() {
global $current_month_num;
$themes = array(
'01' => array('emoji' => '🥂', 'color' => 'hsl(0, 0%, 75%)'), // January - New Year's (Silver)
'02' => array('emoji' => '💖', 'color' => 'hsl(357, 79%, 54%)'), // February - Valentine's (Red)
'03' => array('emoji' => '🍀', 'color' => 'hsl(120, 100%, 25%)'), // March - St. Patrick's (Green)
'04' => array('emoji' => '🐇', 'color' => 'hsl(60, 100%, 90%)'), // April - Easter (Pastel Yellow)
'05' => array('emoji' => '🎖️', 'color' => 'hsl(220, 100%, 30%)'), // May - Memorial Day (Blue)
'06' => array('emoji' => '🏖️', 'color' => 'hsl(16, 100%, 60%)'), // June - Pride Month (Rainbow)
'07' => array('emoji' => '🎆', 'color' => 'hsl(0, 72%, 50%)'), // July - 4th of July (Red)
'08' => array('emoji' => '📓', 'color' => 'hsl(45, 100%, 60%)'), // August - Back to School (Yellow)
'09' => array('emoji' => '🍁', 'color' => 'hsl(30, 40%, 30%)'), // September - Labor Day (Brown)
'10' => array('emoji' => '🎃', 'color' => 'hsl(25, 100%, 50%)'), // October - Halloween (Orange)
'11' => array('emoji' => '🦃', 'color' => 'hsl(30, 100%, 45%)'), // November - Thanksgiving (Autumn Gold)
'12' => array('emoji' => '🎁', 'color' => 'hsl(0, 72%, 40%)'), // December - Christmas (Red)
);
return $themes[$current_month_num] ?? array('icon' => 'fa-solid fa-calendar', 'color' => 'hsl(0, 0%, 100%)'); // Default: Calendar & White
}
require_once 'settings.php';
require_once 'dashboard.php';
require_once 'report-page.php';
/**
* Register and enqueue a custom stylesheet in the admin
*/
function pubcounts_enqueue_admin_assets() {
$screen = get_current_screen();
$targets = [
'dashboard',
'published-counts_page_pubcounts_settings',
'toplevel_page_pubcounts_report'
];
wp_register_style( 'pubc', plugin_dir_url( __FILE__ ) . 'styles/published-counts.css', false, PUBCOUNTS_VERSION );
if ( in_array( $screen->base, $targets ) ) {
wp_enqueue_style( 'pubc' );
}
}
add_action( 'admin_enqueue_scripts', 'pubcounts_enqueue_admin_assets' );
function pubcounts_load_admin_js() {
add_action( 'admin_enqueue_scripts', 'pubcounts_enqueue_admin_js' );
}
function pubcounts_enqueue_admin_js() {
// wp_register_script( 'pubcscript', plugin_dir_url( __FILE__ ) . 'js/published-counts.js', [ 'jquery' ], PUBCOUNTS_VERSION );
// wp_enqueue_script( 'pubcscript' );
}