-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilters.php
More file actions
71 lines (68 loc) · 2.62 KB
/
filters.php
File metadata and controls
71 lines (68 loc) · 2.62 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
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
add_action('wp_footer','qckply_clone_footer_message');
add_action('admin_footer','qckply_clone_footer_message');
function qckply_clone_footer_message() {
if(!get_option('is_qckply_clone')) {
return;
}
$url_nopath = str_replace(trim(qckply_playground_path()),'',sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI'])));
$slug = trim(preg_replace('/[^A-Za-z0-9]/','-',$url_nopath),'-');
if(is_home() || is_front_page())
$slug = 'home';
$keymessage = array('key'=>$slug,'message'=>'');
$keymessage = apply_filters('qckply_key_message',$keymessage);
if(!empty($keymessage['message'])) {
?>
<div id="qckply-overlay-message">
<span><p><strong>Playground Prompt</strong></p>
<?php
echo wp_kses_post(wpautop($keymessage['message']));
?>
</span>
<button id="playground-overlay-close">×</button>
</div>
<?php
}
}
add_filter('qckply_key_message','qckply_key_message');
function qckply_key_message($keymessage) {
if(!empty($_GET['qckply_clone']))
return $keymessage;
$landing = trim(preg_replace('/[^A-Za-z0-9]/','-',get_option('qckply_landing')),'-');
$show = get_option('show_playground_prompt_keys');
extract($keymessage);//key, message, welcome
$messages = qckply_get_prompt_messages();
$welcome_shown = get_transient('qckply_welcome_shown');
$type = get_post_type();
if(isset($messages[$key])) {
if(!empty($messages[$key])) {
$keymessage['message'] .= $messages[$key];
}
}
elseif(!$welcome_shown && !empty($messages['welcome'] && (('home' == $key && empty($landing)) || ($landing == $key)))) {
$keymessage['message'] .= $messages['welcome'];
$key = 'welcome';
set_transient('qckply_welcome_shown',true,DAY_IN_SECONDS);
}
elseif(isset($messages['post_type:'.$type])) {
if(!empty($messages['post_type:'.$type]))
{
$keymessage['message'] .= $messages['post_type:'.$type];
}
}
/*
else {
$keymessage['message'] = sprintf('No prompt message found for key%s landing %s show %s',$key,$landing,var_export($show,true));
}
*/
if($show) {
$url = admin_url('admin.php?page=qckply_clone_prompts&key='.$key);
$keymessage['message'] .= "\n\n".sprintf('Edit message for <a href="%s">%s</a>',$url,$key);
if($key != $keymessage['key']) {
$url = admin_url('admin.php?page=qckply_clone_prompts&key='.$keymessage['key']);
$keymessage['message'] .= sprintf(' or <a href="%s">%s</a>',$url,$keymessage['key']);
}
}
return $keymessage;
}