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 / ctl-timeline-header.php

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

100 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals -- Legacy ctl_* helpers/hooks are intentionally public for addon interoperability.
3 /**
4 * Cool Timeline — global header screen check and hook wiring.
5 *
6 * @package CoolTimeline
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! function_exists( 'ctl_is_timeline_addon_page' ) ) {
14 /**
15 * Whether the current admin screen belongs to the Timeline Addons menu.
16 *
17 * @return bool
18 */
19 function ctl_is_timeline_addon_page() {
20 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
21 $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
22
23 if ( in_array( $page, array( 'cool_timeline_settings', 'ctl-getting-started', 'cool-plugins-timeline-addon', 'timeline-addons-license' ), true ) ) {
24 return true;
25 }
26
27 $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
28
29 if ( $screen && 'cool_timeline' === $screen->post_type ) {
30 return true;
31 }
32
33 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
34 $post_type = isset( $_GET['post_type'] ) ? sanitize_key( wp_unslash( $_GET['post_type'] ) ) : '';
35
36 if ( 'cool_timeline' === $post_type ) {
37 return true;
38 }
39
40 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
41 if ( isset( $_GET['post'] ) ) {
42 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only screen detection.
43 $post_id = absint( wp_unslash( $_GET['post'] ) );
44 if ( $post_id && 'cool_timeline' === get_post_type( $post_id ) ) {
45 return true;
46 }
47 }
48
49 return false;
50 }
51 }
52
53 require_once __DIR__ . '/timeline-global-header.php';
54
55 add_action(
56 'admin_enqueue_scripts',
57 static function () {
58 if ( ! ctl_is_timeline_addon_page() ) {
59 return;
60 }
61
62 $version = defined( 'CTL_V' ) ? CTL_V : '1.0.0';
63 cp_timeline_header_enqueue_styles( $version );
64 }
65 );
66
67 add_filter(
68 'admin_body_class',
69 static function ( $classes ) {
70 if ( ctl_is_timeline_addon_page() ) {
71 $classes .= ' ctl-timeline-addon-page cph-timeline-addon-page';
72 }
73
74 return $classes;
75 }
76 );
77
78 add_action(
79 'in_admin_header',
80 static function () {
81 if ( ! ctl_is_timeline_addon_page() ) {
82 return;
83 }
84 $default_heading = __( 'Timeline Addons', 'cool-timeline' );
85 $heading = apply_filters( 'ctl_global_header_heading', $default_heading );
86 $utm_params = '?utm_source=ctl_plugin&utm_medium=inside&utm_campaign=docs&utm_content=global-header';
87 cp_timeline_header_render(
88 array(
89 'heading' => $heading,
90 'icon_url' => CTL_PLUGIN_URL . 'assets/images/timeline-icon.svg',
91 'docs_url' => 'https://cooltimeline.com/docs/' . $utm_params,
92 'support_url' => 'https://coolplugins.net/support/' . $utm_params,
93 'docs_label' => __( 'Check Docs', 'cool-timeline' ),
94 'support_label' => __( 'Get Support', 'cool-timeline' ),
95 'text_domain' => 'cool-timeline',
96 )
97 );
98 }
99 );
100