class-ld-settings-section-side-quick-links.php
3.3 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
<?php
/**
* LearnDash Settings Section Side Quick Links Metabox.
*
* @since 2.6.0
* @package LearnDash\Settings\Sections
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ( class_exists( 'LearnDash_Settings_Section' ) ) && ( ! class_exists( 'LearnDash_Settings_Section_Side_Quick_Links' ) ) ) {
/**
* Class LearnDash Settings Section Side Quick Links Metabox.
*
* @since 2.6.0
*/
class LearnDash_Settings_Section_Side_Quick_Links extends LearnDash_Settings_Section {
/**
* Public constructor for class
*
* @since 2.6.0
*
* @param array $args Array of class args.
*/
public function __construct( $args = array() ) {
if ( ( isset( $args['settings_screen_id'] ) ) && ( ! empty( $args['settings_screen_id'] ) ) ) {
$this->settings_screen_id = $args['settings_screen_id'];
}
if ( ( isset( $args['settings_page_id'] ) ) && ( ! empty( $args['settings_page_id'] ) ) ) {
$this->settings_page_id = $args['settings_page_id'];
}
if ( ( ! empty( $this->settings_screen_id ) ) && ( ! empty( $this->settings_page_id ) ) ) {
// This is the 'option_name' key used in the wp_options table.
$this->setting_option_key = 'quick_links_div';
// Section label/header.
$this->settings_section_label = esc_html__( 'Quick Links', 'learndash' );
$this->metabox_context = 'side';
$this->metabox_priority = 'high';
parent::__construct();
}
}
/**
* Show custom metabox output for Quick Links.
*
* @since 2.6.0
*/
public function show_meta_box() {
global $wp_meta_boxes;
?>
<div id="ld_quick-links" class="submitbox">
<?php
$q_links = array();
if ( ( isset( $wp_meta_boxes[ $this->settings_screen_id ] ) ) && ( ! empty( $wp_meta_boxes[ $this->settings_screen_id ] ) ) ) {
foreach ( $wp_meta_boxes[ $this->settings_screen_id ] as $mb_context => $mb_set_priority ) {
if ( 'side' !== $mb_context ) {
foreach ( $mb_set_priority as $priority => $mb_set ) {
if ( ! empty( $mb_set ) ) {
foreach ( $mb_set as $mb ) {
if ( ( ! empty( $mb['id'] ) ) && ( ! empty( $mb['title'] ) ) ) {
$q_links[ $mb['id'] ] = $mb['title'];
}
}
}
}
}
}
if ( ! empty( $q_links ) ) {
echo '<ul>';
$meta_box_order = get_user_option( 'meta-box-order_' . $this->settings_screen_id );
if ( ( isset( $meta_box_order['normal'] ) ) && ( ! empty( $meta_box_order['normal'] ) ) ) {
$meta_box_order_items = explode( ',', $meta_box_order['normal'] );
foreach ( $meta_box_order_items as $meta_box_order_item ) {
$meta_box_order_item = trim( $meta_box_order_item );
if ( isset( $q_links[ $meta_box_order_item ] ) ) {
echo '<li><a href="#' . esc_attr( $meta_box_order_item ) . '" >' . esc_html( $q_links[ $meta_box_order_item ] ) . '</a></li>';
unset( $q_links[ $meta_box_order_item ] );
}
}
}
if ( ! empty( $q_links ) ) {
foreach ( $q_links as $link_id => $link_title ) {
echo '<li><a href="#' . esc_attr( $link_id ) . '" >' . esc_html( $link_title ) . '</a></li>';
}
}
echo '</ul>';
}
}
?>
</div><!-- #submitpost -->
<?php
}
/**
* Load settings fields
*
* This is a requires function.
*/
public function load_settings_fields() {
}
}
}