PluginProbe
Fast Chat Button / trunk
Fast Chat Button vtrunk
trunk 1.0.0 1.0.1 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1
fast-chat-button / include / functions.php

functions.php in Fast Chat Button trunk, at include/functions.php

116 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3
4 // ==================================================================
5 // output the values into the the page or input in the correct way
6 // allowing to have double and single quotes inside input
7 // ==================================================================
8
9 function yydev_chat_btn_html_output($output_code) {
10
11 $output_code = stripslashes_deep($output_code);
12 $output_code = esc_html($output_code);
13 return $output_code;
14
15 } // function yydev_chat_btn_html_output($output_code) {
16
17 // ==================================================================
18 // This function will display error message if there was something wrong
19 // $error_message will be the name of the string we define and if it's exists
20 // it will echo the message to the page
21 // if $display_inline is set to 1 it will have style of display: inline
22 // ==================================================================
23
24 function yydev_chat_btn_show_error_message($error_message, $display_inline = "") {
25
26 if($display_inline == 1) {
27 $display_inline_echo = "display-inline";
28 } // if($display_inline == 1) {
29
30 if( isset($error_message) ) {
31 ?>
32
33 <div class="output-data-error-message <?php echo $display_inline_echo; ?>">
34 <?php echo $error_message; ?>
35 </div>
36
37 <?php
38 } // if( isset($error) ) {
39
40 } // function yydev_chat_btn_show_error_message($error) {
41
42
43 // ==================================================================
44 // Cehcking if the checkbox is already set
45 // ==================================================================
46
47 function yydev_chat_btn_checkbox_isset($post_value) {
48
49 $checkbox_value = '';
50
51 if( isset( $_POST[$post_value] ) ) {
52 $checkbox_value = intval($_POST[$post_value]);
53 } // if( isset( $_POST[$post_value] ) ) {
54
55 return $checkbox_value;
56
57 } // function yydev_chat_btn_checkbox_isset($error) {
58
59 // ================================================
60 // Echoing Message if it's exists
61 // ================================================
62
63 function yydev_chat_btn_echo_success_message_if_exists($success) {
64
65 if(isset($success) && !empty($success) ) {
66 echo "<div class='output-messsage'> " . htmlentities($success) . " </div>";
67 } // if(isset($success) && !empty($success) ) {
68
69 } // function yydev_chat_btn_echo_success_message_if_exists($success) {
70
71 function yydev_chat_btn_echo_error_message_if_exists($error) {
72
73 if(isset($error) && !empty($error) ) {
74 echo "<div class='error-messsage'><b>Error:</b> " . $error . " </div>";
75 } // if(isset($_GET['error-message'])) {
76
77 } // function yydev_chat_btn_echo_error_message_if_exists() {
78
79 // ================================================
80 // Echoing Message if it's exists
81 // ================================================
82
83 function yydev_chat_btn_find_page_id() {
84
85 global $wpdb;
86 $post_id_num = 0;
87
88 // in case of page or blog post
89 if( is_single() || is_page() ) {
90 $post_id_num = get_the_ID();
91 } // if( is_single() || is_page() ) {
92
93 // in case of static home page
94 if( is_home() ) {
95 $blog_page_id = get_option( 'page_for_posts' );
96
97 // incase the blog is on the home page
98 if( !empty($blog_page_id) ) {
99 $post_id_num = $blog_page_id;
100 } // if( $blog_page_id ) {
101
102 } // if( !empty($blog_page_id) ) {
103
104 return intval($post_id_num);
105
106 } // function yydev_chat_btn_find_page_id() {
107
108 // ==================================================================
109 // redirect the page using the path you provided
110 // ==================================================================
111
112 function yydev_chat_btn_redirections_page($link) {
113 header("Location: {$link}");
114 exit;
115 } // function yydev_chat_btn_redirections_page($path) {
116