| 1 |
<?php // Prismatic - Settings Callbacks |
| 2 |
|
| 3 |
if (!defined('ABSPATH')) exit; |
| 4 |
|
| 5 |
function prismatic_section_general() { |
| 6 |
|
| 7 |
echo '<p>'. esc_html__('Thank you for using the free version of', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/plugins/prismatic/">'. esc_html__('Prismatic', 'prismatic') .'</a>.</p>'; |
| 8 |
|
| 9 |
} |
| 10 |
|
| 11 |
function prismatic_section_prism() { |
| 12 |
|
| 13 |
echo '<p>'. esc_html__('Settings for syntax highlighting via', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="http://prismjs.com/">'. esc_html__('Prism.js', 'prismatic') .'</a>.</p>'; |
| 14 |
|
| 15 |
} |
| 16 |
|
| 17 |
function prismatic_section_prism_code() { |
| 18 |
|
| 19 |
echo '<p>'. esc_html__('Settings for code escaping when Prism.js is enabled.', 'prismatic') .'</p>'; |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
function prismatic_section_highlight() { |
| 24 |
|
| 25 |
echo '<p>'. esc_html__('Settings for syntax highlighting via', 'prismatic') .' <a target="_blank" rel="noopener noreferrer" href="https://highlightjs.org/">'. esc_html__('Highlight.js', 'prismatic') .'</a>.</p>'; |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
function prismatic_section_highlight_code() { |
| 30 |
|
| 31 |
echo '<p>'. esc_html__('Settings for code escaping when Highlight.js is enabled.', 'prismatic') .'</p>'; |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
function prismatic_section_plain() { |
| 36 |
|
| 37 |
echo '<p>'. esc_html__('Settings for code escaping without syntax highlighting.', 'prismatic') .'</p>'; |
| 38 |
|
| 39 |
} |
| 40 |
|
| 41 |
function prismatic_library() { |
| 42 |
|
| 43 |
$library = array( |
| 44 |
|
| 45 |
'prism' => array( |
| 46 |
'value' => 'prism', |
| 47 |
'label' => esc_html__('Prism.js', 'prismatic'), |
| 48 |
), |
| 49 |
'highlight' => array( |
| 50 |
'value' => 'highlight', |
| 51 |
'label' => esc_html__('Highlight.js', 'prismatic'), |
| 52 |
), |
| 53 |
'plain' => array( |
| 54 |
'value' => 'plain', |
| 55 |
'label' => esc_html__('Plain Flavor', 'prismatic'), |
| 56 |
), |
| 57 |
'none' => array( |
| 58 |
'value' => 'none', |
| 59 |
'label' => esc_html__('None (Disable)', 'prismatic'), |
| 60 |
), |
| 61 |
); |
| 62 |
|
| 63 |
return $library; |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
function prismatic_location() { |
| 68 |
|
| 69 |
$array = array( |
| 70 |
|
| 71 |
'front' => array( |
| 72 |
'value' => 'front', |
| 73 |
'label' => esc_html__('Frontend only', 'prismatic'), |
| 74 |
), |
| 75 |
'admin' => array( |
| 76 |
'value' => 'admin', |
| 77 |
'label' => esc_html__('Admin Area only', 'prismatic'), |
| 78 |
), |
| 79 |
'both' => array( |
| 80 |
'value' => 'both', |
| 81 |
'label' => esc_html__('Frontend & Admin Area', 'prismatic'), |
| 82 |
), |
| 83 |
'none' => array( |
| 84 |
'value' => 'none', |
| 85 |
'label' => esc_html__('None (Disable)', 'prismatic'), |
| 86 |
), |
| 87 |
); |
| 88 |
|
| 89 |
return $array; |
| 90 |
|
| 91 |
} |
| 92 |
|
| 93 |
function prismatic_prism_theme() { |
| 94 |
|
| 95 |
$theme = array( |
| 96 |
|
| 97 |
'coy' => array( |
| 98 |
'value' => 'coy', |
| 99 |
'label' => esc_html__('Coy', 'prismatic'), |
| 100 |
), |
| 101 |
'dark' => array( |
| 102 |
'value' => 'dark', |
| 103 |
'label' => esc_html__('Dark', 'prismatic'), |
| 104 |
), |
| 105 |
'default' => array( |
| 106 |
'value' => 'default', |
| 107 |
'label' => esc_html__('Default', 'prismatic'), |
| 108 |
), |
| 109 |
'funky' => array( |
| 110 |
'value' => 'funky', |
| 111 |
'label' => esc_html__('Funky', 'prismatic'), |
| 112 |
), |
| 113 |
'okaidia' => array( |
| 114 |
'value' => 'okaidia', |
| 115 |
'label' => esc_html__('Okaidia', 'prismatic'), |
| 116 |
), |
| 117 |
'solarized' => array( |
| 118 |
'value' => 'solarized', |
| 119 |
'label' => esc_html__('Solarized', 'prismatic'), |
| 120 |
), |
| 121 |
'tomorrow-night' => array( |
| 122 |
'value' => 'tomorrow-night', |
| 123 |
'label' => esc_html__('Tomorrow Night', 'prismatic'), |
| 124 |
), |
| 125 |
'twilight' => array( |
| 126 |
'value' => 'twilight', |
| 127 |
'label' => esc_html__('Twilight', 'prismatic'), |
| 128 |
), |
| 129 |
); |
| 130 |
|
| 131 |
return $theme; |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
function prismatic_highlight_theme() { |
| 136 |
|
| 137 |
require_once PRISMATIC_DIR .'lib/highlight/themes.php'; |
| 138 |
|
| 139 |
return $theme; |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
function prismatic_callback_select($args) { |
| 144 |
|
| 145 |
$id = isset($args['id']) ? $args['id'] : ''; |
| 146 |
$label = isset($args['label']) ? $args['label'] : ''; |
| 147 |
$section = isset($args['section']) ? $args['section'] : ''; |
| 148 |
|
| 149 |
$setting = 'prismatic_options_'. $section; |
| 150 |
|
| 151 |
global ${$setting}; |
| 152 |
|
| 153 |
$options = ${$setting}; |
| 154 |
|
| 155 |
$value = isset($options[$id]) ? sanitize_text_field($options[$id]) : ''; |
| 156 |
|
| 157 |
$options_array = array(); |
| 158 |
|
| 159 |
if ($id === 'library') { |
| 160 |
|
| 161 |
$options_array = prismatic_library(); |
| 162 |
|
| 163 |
} elseif ($id === 'filter_content' || $id === 'filter_excerpts' || $id === 'filter_comments') { |
| 164 |
|
| 165 |
$options_array = prismatic_location(); |
| 166 |
|
| 167 |
} elseif ($id === 'prism_theme') { |
| 168 |
|
| 169 |
$options_array = prismatic_prism_theme(); |
| 170 |
|
| 171 |
} elseif ($id === 'highlight_theme') { |
| 172 |
|
| 173 |
$options_array = prismatic_highlight_theme(); |
| 174 |
|
| 175 |
} |
| 176 |
|
| 177 |
echo '<select name="'. $setting .'['. $id .']">'; |
| 178 |
|
| 179 |
foreach ($options_array as $option) { |
| 180 |
echo '<option '. selected($option['value'], $value, false) .' value="'. $option['value'] .'">'. $option['label'] .'</option>'; |
| 181 |
} |
| 182 |
echo '</select> <label class="prismatic-label inline-block" for="'. $setting .'['. $id .']">'. $label .'</label>'; |
| 183 |
|
| 184 |
} |
| 185 |
|
| 186 |
function prismatic_callback_text($args) { |
| 187 |
|
| 188 |
$id = isset($args['id']) ? $args['id'] : ''; |
| 189 |
$label = isset($args['label']) ? $args['label'] : ''; |
| 190 |
$section = isset($args['section']) ? $args['section'] : ''; |
| 191 |
|
| 192 |
$setting = 'prismatic_options_'. $section; |
| 193 |
|
| 194 |
global ${$setting}; |
| 195 |
|
| 196 |
$options = ${$setting}; |
| 197 |
|
| 198 |
$value = isset($options[$id]) ? sanitize_text_field($options[$id]) : ''; |
| 199 |
|
| 200 |
echo '<input name="'. $setting .'['. $id .']" type="text" size="40" value="'. $value .'"> '; |
| 201 |
echo '<label for="'. $setting .'['. $id .']" class="prismatic-label">'. $label .'</label>'; |
| 202 |
|
| 203 |
} |
| 204 |
|
| 205 |
function prismatic_callback_textarea($args) { |
| 206 |
|
| 207 |
$id = isset($args['id']) ? $args['id'] : ''; |
| 208 |
$label = isset($args['label']) ? $args['label'] : ''; |
| 209 |
$section = isset($args['section']) ? $args['section'] : ''; |
| 210 |
|
| 211 |
$setting = 'prismatic_options_'. $section; |
| 212 |
|
| 213 |
global ${$setting}; |
| 214 |
|
| 215 |
$options = ${$setting}; |
| 216 |
|
| 217 |
$allowed_tags = wp_kses_allowed_html('post'); |
| 218 |
|
| 219 |
$value = isset($options[$id]) ? wp_kses(stripslashes_deep($options[$id]), $allowed_tags) : ''; |
| 220 |
|
| 221 |
echo '<textarea name="'. $setting .'['. $id .']" rows="3" cols="50">'. $value .'</textarea> '; |
| 222 |
echo '<label for="'. $setting .'['. $id .']" class="prismatic-label" >'. $label .'</label>'; |
| 223 |
|
| 224 |
} |
| 225 |
|
| 226 |
function prismatic_callback_checkbox($args) { |
| 227 |
|
| 228 |
$id = isset($args['id']) ? $args['id'] : ''; |
| 229 |
$label = isset($args['label']) ? $args['label'] : ''; |
| 230 |
$section = isset($args['section']) ? $args['section'] : ''; |
| 231 |
|
| 232 |
$setting = 'prismatic_options_'. $section; |
| 233 |
|
| 234 |
global ${$setting}; |
| 235 |
|
| 236 |
$options = ${$setting}; |
| 237 |
|
| 238 |
$checked = isset($options[$id]) ? checked($options[$id], 1, false) : ''; |
| 239 |
|
| 240 |
echo '<input name="'. $setting .'['. $id .']" value="1" type="checkbox" '. $checked .'> '; |
| 241 |
echo '<label for="'. $setting .'['. $id .']" class="prismatic-label inline-block">'. $label .'</label>'; |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
function prismatic_callback_number($args) { |
| 246 |
|
| 247 |
$id = isset($args['id']) ? $args['id'] : ''; |
| 248 |
$label = isset($args['label']) ? $args['label'] : ''; |
| 249 |
$section = isset($args['section']) ? $args['section'] : ''; |
| 250 |
|
| 251 |
$setting = 'prismatic_options_'. $section; |
| 252 |
|
| 253 |
global ${$setting}; |
| 254 |
|
| 255 |
$options = ${$setting}; |
| 256 |
|
| 257 |
$value = isset($options[$id]) ? sanitize_text_field($options[$id]) : ''; |
| 258 |
|
| 259 |
$min = 0; |
| 260 |
$max = 999; |
| 261 |
|
| 262 |
echo '<input name="'. $setting .'['. $id .']" type="number" min="'. $min .'" max="'. $max .'" value="'. $value .'"> '; |
| 263 |
echo '<label for="'. $setting .'['. $id .']" class="prismatic-label inline-block">'. $label .'</label>'; |
| 264 |
|
| 265 |
} |
| 266 |
|
| 267 |
function prismatic_callback_reset($args) { |
| 268 |
|
| 269 |
$nonce = wp_create_nonce('prismatic_reset_options'); |
| 270 |
$url = admin_url('options-general.php?page=prismatic'); |
| 271 |
$href = esc_url(add_query_arg(array('reset-options-verify' => $nonce), $url)); |
| 272 |
|
| 273 |
echo '<a class="prismatic-reset-options" href="'. $href .'">'. esc_html__('Restore default plugin options', 'prismatic') .'</a>'; |
| 274 |
|
| 275 |
} |
| 276 |
|
| 277 |
function prismatic_callback_rate($args) { |
| 278 |
|
| 279 |
$href = 'https://wordpress.org/support/plugin/'. PRISMATIC_SLUG .'/reviews/?rate=5#new-post'; |
| 280 |
$title = esc_attr__('Help keep Prismatic going strong! A huge THANK YOU for your support!', 'prismatic'); |
| 281 |
$text = isset($args['label']) ? $args['label'] : esc_html__('Show support with a 5-star rating »', 'prismatic'); |
| 282 |
|
| 283 |
echo '<a target="_blank" rel="noopener noreferrer" class="prismatic-rate-plugin" href="'. $href .'" title="'. $title .'">'. $text .'</a>'; |
| 284 |
|
| 285 |
} |
| 286 |
|