Diff: STRATO-apps/wordpress_03/app/wp-content/themes/blocksy/inc/meta-boxes.php

Keine Baseline-Datei – Diff nur gegen leer.
Zur Liste
1 -
1 + <?php
2 + /**
3 + * Implement meta boxes
4 + *
5 + * @copyright 2019-present Creative Themes
6 + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
7 + * @package Blocksy
8 + */
9 +
10 + function blocksy_get_post_options($post_id = null, $args = []) {
11 + $args = wp_parse_args(
12 + $args,
13 + [
14 + 'meta_id' => 'blocksy_post_meta_options'
15 + ]
16 + );
17 +
18 + static $post_opts = [];
19 +
20 + if (! $post_id) {
21 + global $post;
22 +
23 + if ($post && is_singular()) {
24 + $post_id = $post->ID;
25 + }
26 +
27 + $maybe_page = blocksy_is_page();
28 +
29 + if ($maybe_page) {
30 + $post_id = $maybe_page;
31 + }
32 +
33 + if (! $post_id) {
34 + $object = get_queried_object();
35 +
36 + if (isset($object->ID)) {
37 + $post_id = $object->ID;
38 + }
39 + }
40 + }
41 +
42 + if (is_array($post_id)) {
43 + blocksy_debug_log(
44 + 'blocksy_get_post_options() post_id is array. This is not valid.',
45 + [
46 + 'post_id' => $post_id,
47 + 'is_page' => blocksy_is_page(),
48 + 'args' => $args
49 + ]
50 + );
51 +
52 + return [];
53 + }
54 +
55 + $cache_key = $post_id . ':' . $args['meta_id'];
56 +
57 + if (isset($post_opts[$cache_key])) {
58 + return $post_opts[$cache_key];
59 + }
60 +
61 + $values = get_post_meta($post_id, $args['meta_id']);
62 +
63 + if (empty($values)) {
64 + $values = [[]];
65 + }
66 +
67 + if (! is_array($values[0]) || ! $values[0]) {
68 + return [];
69 + }
70 +
71 + $final_values = $values[0];
72 +
73 + // inc/options/meta/blog.php
74 + $allowed_keys_for_special_posts = apply_filters(
75 + 'blocksy:posts:meta:blog-special-keys',
76 + [
77 + 'disable_header',
78 + 'disable_footer',
79 + ]
80 + );
81 +
82 + if (
83 + intval(get_option('page_for_posts')) === intval($post_id)
84 + ||
85 + intval(get_option('woocommerce_shop_page_id')) === intval($post_id)
86 + ) {
87 + foreach ($values[0] as $key => $value) {
88 + if (! in_array($key, $allowed_keys_for_special_posts)) {
89 + unset($final_values[$key]);
90 + }
91 + }
92 + }
93 +
94 + $final_values = apply_filters(
95 + 'blocksy:posts:meta:values',
96 + $final_values,
97 + $post_id
98 + );
99 +
100 + $post_opts[$cache_key] = $final_values;
101 +
102 + return $final_values;
103 + }
104 +
105 + function blocksy_get_taxonomy_options($term_id = null) {
106 + static $taxonomy_opts = [];
107 +
108 + if (! $term_id) {
109 + $term_id = get_queried_object_id();
110 + }
111 +
112 + if (isset($taxonomy_opts[$term_id])) {
113 + return $taxonomy_opts[$term_id];
114 + }
115 +
116 + $values = get_term_meta(
117 + $term_id,
118 + 'blocksy_taxonomy_meta_options'
119 + );
120 +
121 + if (
122 + empty($values)
123 + ||
124 + ! is_array($values[0])
125 + ||
126 + ! $values[0]
127 + ) {
128 + $values = [[]];
129 + }
130 +
131 + $taxonomy_opts[$term_id] = $values[0];
132 +
133 + return $values[0];
134 + }
135 +
136 +