PluginProbe
Cool Timeline (Horizontal & Vertical Timeline) / trunk
Cool Timeline (Horizontal & Vertical Timeline) vtrunk
3.4.0 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 2.2.3 2.3.3 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.6.1 2.7.1 2.8.3 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 All 79 releases
cool-timeline / admin / timeline-global-header.php

timeline-global-header.php in Cool Timeline (Horizontal & Vertical Timeline) trunk, at admin/timeline-global-header.php

363 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.WP.I18n.NonSingularStringLiteralDomain,WordPress.NamingConventions.PrefixAllGlobals -- Dynamic text domain and shared cp_* header helpers are intentional.
3 /**
4 * Shared Timeline Addons admin header template.
5 *
6 * Copy this file identically into each Cool Timeline addon plugin.
7 * Each addon loads it with require_once and calls render/enqueue only on its own screens.
8 *
9 * @package CoolPlugins\TimelineHeader
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 if ( ! function_exists( 'cp_timeline_header_get_css' ) ) {
17 /**
18 * Return inline CSS for the global header.
19 *
20 * @return string
21 */
22 function cp_timeline_header_get_css() {
23 return '
24 .cph-top-header {
25 --cph-primary: #2e9e9d;
26 --cph-primary-dark: #257f7e;
27 --cph-border: #e2e8f0;
28
29 position: relative;
30 display: flex;
31 justify-content: space-between;
32 align-items: center;
33 box-sizing: border-box;
34 width: calc(100% + 20px);
35 left:-20px;
36 margin: 0 0 16px;
37 padding: 0 20px 0 2px;
38 background-color: #ffffff;
39 border-bottom: 1px solid #ddd;
40 height: 62px;
41 box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
42 z-index: 99;
43 }
44
45 .cph-header-left .cph-header-img-box {
46 width: 35px;
47 height: 35px;
48 }
49
50 .cph-header-left .cph-header-img-box img {
51 width: 100%;
52 height: 100%;
53 }
54
55 .cph-top-header .cph-header-left {
56 display: flex;
57 align-items: center;
58 gap: 12px;
59 margin-left: 20px;
60 }
61
62 .cph-header-left h1 {
63 font-size: 19px;
64 font-weight: 700;
65 margin: 0;
66 line-height: 1.2;
67 }
68
69 .cph-top-header .cph-header-right {
70 display: flex;
71 gap: 12px;
72 margin-right: 0;
73 flex-shrink: 0;
74 }
75 .cph-header-right a .dashicons-editor-help {
76 font-size: 28px!important;
77 width: 28px!important;
78 height: 28px!important;
79 left: 0!important;
80 top: 0!important;
81 color: var(--cpo-primary)!important;
82 }
83
84 .cph-top-header .cph-header-right svg {
85 width: 17px;
86 height: 18px;
87 }
88
89 .cph-top-header .cph-header-right a:focus {
90 box-shadow: none !important;
91 }
92
93
94 /* --- Buttons (scoped WordPress .button restyle) --- */
95
96 .cph-top-header a.cph-btn ,
97 .cph-top-header button.cph-btn {
98 display: inline-flex;
99 align-items: center;
100 justify-content: center;
101 gap: 8px;
102 padding: 8px 12px;
103 border: 1px solid;
104 border-radius: 6px;
105 cursor: pointer;
106 font-size: 14px;
107 line-height: 1.35;
108 font-weight: 600;
109 text-align: center;
110 text-decoration: none;
111 white-space: nowrap;
112 box-shadow: none;
113 transition:
114 background-color 0.15s ease,
115 border-color 0.15s ease,
116 color 0.15s ease,
117 box-shadow 0.15s ease,
118 transform 0.05s ease;
119 }
120
121 .cph-top-header a.cph-btn:focus,
122 .cph-top-header a.cph-btn:visited,
123 .cph-top-header button.cph-btn:focus,
124 .cph-top-header button.cph-btn:visited {
125 box-shadow: none !important;
126 }
127
128 .cph-top-header a.cph-btn:hover,
129 .cph-top-header button.cph-btn:hover {
130 box-shadow: none !important;
131
132 background: #069392;
133 color: #fff !important;
134 }
135
136 .cph-top-header a.cph-btn:active,
137 .cph-top-header button.cph-btn:active {
138 box-shadow: none !important;
139
140 background: #069392;
141 color: #fff !important;
142 }
143 .cph-top-header a.cph-btn:focus,
144 .cph-top-header a.cph-btn:visited,
145 .cph-top-header button.cph-btn:focus,
146 .cph-top-header button.cph-btn:visited {
147 box-shadow: none !important;
148 }
149
150 .cph-top-header a.cph-btn-outline,
151 .cph-top-header button.cph-btn-outline {
152 background: #fff;
153 border-color: var(--cph-primary);
154 color: var(--cph-primary);
155 }
156
157 .cph-top-header a.cph-btn-primary,
158 .cph-top-header button.cph-btn-primary {
159 background: var(--cph-primary);
160 border-color: var(--cph-primary);
161 color: #fff;
162 box-shadow: 0 1px 2px rgba(0, 124, 122, 0.22);
163 }
164
165 .cph-top-header a.cph-btn-primary,
166 .cph-top-header button.cph-btn-primary {
167 background: #15AAA9;
168 border: none;
169 color: #fff !important;
170 }
171
172 .cph-top-header a.cph-btn-primary:focus,
173 .cph-top-header a.cph-btn-primary:visited,
174 .cph-top-header button.cph-btn-primary:focus,
175 .cph-top-header button.cph-btn-primary:visited {
176 box-shadow: none !important;
177 }
178
179 .cph-top-header a.cph-btn-primary:hover,
180 .cph-top-header button.cph-btn-primary:hover {
181 box-shadow: none !important;
182 border: none;
183 background: #069392;
184 color: #fff !important;
185 }
186
187
188
189
190 .cph-header-notices {
191 margin: 0 20px 16px 2px;
192 }
193
194 .cph-header-notices:empty {
195 display: none;
196 margin: 0;
197 }
198
199 .cph-header-notices .notice,
200 .cph-header-notices [class*="_admin_notice"] {
201 margin-top: 0;
202 margin-bottom: 10px;
203 }
204
205 body.cph-timeline-addon-page .wrap {
206 margin-top: 0;
207 }
208
209 body.cph-timeline-addon-page .wrap.cpo-onboarding-page {
210 margin-top: 0;
211 max-width: 100%;
212 }
213
214 body.cph-timeline-addon-page.post-type-cool_timeline.edit-php .wrap > h1.wp-heading-inline {
215 display: none;
216 }
217
218 body.cph-timeline-addon-page.post-type-cool_timeline.post-new-php .wrap > h1,
219 body.cph-timeline-addon-page.post-type-cool_timeline.post-php .wrap > h1 {
220 display: none;
221 }
222
223 body.cph-timeline-addon-page.cool-plugins-timeline-addon_page_cool_timeline_settings .csf-header {
224 display: none;
225 }
226
227 @media screen and (max-width: 782px) {
228 .cph-top-header {
229 padding: 0 10px;
230 height: auto;
231 min-height: 62px;
232 }
233
234 .cph-header-left h1 {
235 font-size: 15px;
236 }
237
238 .cph-btn {
239 padding: 6px 12px;
240 font-size: 12px;
241 }
242
243 .cph-header-notices {
244 margin-left: 10px;
245 margin-right: 10px;
246 }
247 }
248
249 @media screen and (max-width: 480px) {
250 .cph-top-header {
251 flex-direction: column;
252 height: auto;
253 padding: 15px 10px;
254 gap: 12px;
255 text-align: center;
256 }
257
258 .cph-top-header .cph-header-left,
259 .cph-top-header .cph-header-right {
260 width: 100%;
261 justify-content: center;
262 }
263 }';
264 }
265 }
266
267 if ( ! function_exists( 'cp_timeline_header_enqueue_styles' ) ) {
268 /**
269 * Enqueue inline header styles (call only on screens where the header renders).
270 *
271 * @param string $version Asset version string.
272 * @return void
273 */
274 function cp_timeline_header_enqueue_styles( $version = '1.0.0' ) {
275 $handle = 'cp-timeline-global-header';
276
277 wp_register_style( $handle, false, array(), $version );
278 wp_enqueue_style( $handle );
279 wp_add_inline_style( $handle, cp_timeline_header_get_css() );
280 }
281 }
282
283 if ( ! function_exists( 'cp_timeline_header_render' ) ) {
284 /**
285 * Render the global Timeline Addons admin header.
286 *
287 * @param array $args {
288 * Header configuration.
289 *
290 * @type string $heading Header title.
291 * @type string $icon_url Logo image URL.
292 * @type string $docs_url Documentation button URL.
293 * @type string $support_url Support button URL.
294 * @type string $docs_label Documentation button label.
295 * @type string $support_label Support button label.
296 * @type string $text_domain Text domain for fallbacks.
297 * @type string $prefix CSS class prefix. Default cph.
298 * }
299 * @return void
300 */
301 function cp_timeline_header_render( array $args ) {
302 $defaults = array(
303 'heading' => '',
304 'icon_url' => '',
305 'docs_url' => '',
306 'support_url' => '',
307 'docs_label' => '',
308 'support_label' => '',
309 'text_domain' => 'default',
310 'prefix' => 'cph',
311 );
312
313 $args = wp_parse_args( $args, $defaults );
314 $prefix = sanitize_key( $args['prefix'] );
315
316 if ( '' === $args['docs_label'] ) {
317 $args['docs_label'] = __( 'Check Docs', $args['text_domain'] );
318 }
319 if ( '' === $args['support_label'] ) {
320 $args['support_label'] = __( 'Get Support', $args['text_domain'] );
321 }
322
323 $icon_alt = '' !== $args['heading'] ? $args['heading'] : __( 'Timeline Addons', $args['text_domain'] );
324 ?>
325 <header class="<?php echo esc_attr( $prefix ); ?>-top-header">
326 <div class="<?php echo esc_attr( $prefix ); ?>-header-left">
327 <?php if ( ! empty( $args['icon_url'] ) ) : ?>
328 <div class="<?php echo esc_attr( $prefix ); ?>-header-img-box">
329 <img src="<?php echo esc_url( $args['icon_url'] ); ?>" alt="<?php echo esc_attr( $icon_alt ); ?>">
330 </div>
331 <?php endif; ?>
332 <h1><?php echo esc_html( $args['heading'] ); ?></h1>
333 </div>
334 <div class="<?php echo esc_attr( $prefix ); ?>-header-right">
335 <?php if ( ! empty( $args['support_url'] ) ) : ?>
336 <a href="<?php echo esc_url( $args['support_url'] ); ?>" target="_blank" rel="noopener" class="<?php echo esc_attr( $prefix ); ?>-btn <?php echo esc_attr( $prefix ); ?>-btn-outline">
337 <span class="dashicons dashicons-editor-help"></span>
338 <?php echo esc_html( $args['support_label'] ); ?>
339 </a>
340 <?php endif; ?>
341 <?php if ( ! empty( $args['docs_url'] ) ) : ?>
342 <a href="<?php echo esc_url( $args['docs_url'] ); ?>" target="_blank" rel="noopener" class="<?php echo esc_attr( $prefix ); ?>-btn <?php echo esc_attr( $prefix ); ?>-btn-primary">
343 <span class="dashicons dashicons-book"></span>
344 <?php echo esc_html( $args['docs_label'] ); ?>
345 </a>
346 <?php endif; ?>
347 </div>
348 </header>
349
350 <div class="cph-header-notices">
351 <?php
352 /**
353 * Fires immediately after the Timeline Addons global header.
354 *
355 * Used by admin notices to render below the header on plugin screens.
356 */
357 do_action( 'cph_after_timeline_header' );
358 ?>
359 </div>
360 <?php
361 }
362 }
363