PluginProbe
Phone Button / 2.0.0
Phone Button v2.0.0
trunk 1.0.0 1.0.1 1.0.3 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1 2.1.2
phone-button / include / functions.php

functions.php in Phone Button 2.0.0, at include/functions.php

125 lines 4.4 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 // This function create a content in mysql that will fit the database and will ignore marks like ("", \, =)
6 // ==================================================================
7
8 function yydev_phone_btn_mysql_prep( $value ) {
9 $magic_quotes_active = get_magic_quotes_gpc();
10 $new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0
11 if( $new_enough_php ) { // PHP v4.3.0 or higher
12 // undo any magic quote effects so mysql_real_escape_string can do the work
13 if( $magic_quotes_active ) { $value = stripslashes( $value ); }
14 } else { // before PHP v4.3.0
15 // if magic quotes aren't already on then add slashes manually
16 if( !$magic_quotes_active ) { $value = addslashes( $value ); }
17 // if magic quotes are active, then the slashes already exist
18 }
19 $value = trim($value);
20 $value = stripslashes($value);
21 $value = stripslashes_deep($value);
22
23 return $value;
24 } // function yydev_phone_btn_mysql_prep( $value ) {
25
26 // ==================================================================
27 // This function will display error message if there was something wrong
28 // $error_message will be the name of the string we define and if it's exists
29 // it will echo the message to the page
30 // if $display_inline is set to 1 it will have style of display: inline
31 // ==================================================================
32
33 function yydev_phone_btn_show_error_message($error_message, $display_inline = "") {
34
35 if($display_inline == 1) {
36 $display_inline_echo = "display-inline";
37 } // if($display_inline == 1) {
38
39 if( isset($error_message) ) {
40 ?>
41
42 <div class="output-data-error-message <?php echo $display_inline_echo; ?>">
43 <?php echo $error_message; ?>
44 </div>
45
46 <?php
47 } // if( isset($error) ) {
48
49 } // function yydev_phone_btn_show_error_message($error) {
50
51
52 // ==================================================================
53 // Cehcking if the checkbox is already set
54 // ==================================================================
55
56 function yydev_phone_btn_checkbox_isset($post_value) {
57
58 $checkbox_value = '';
59
60 if( isset( $_POST[$post_value] ) ) {
61 $checkbox_value = intval($_POST[$post_value]);
62 } // if( isset( $_POST[$post_value] ) ) {
63
64 return $checkbox_value;
65
66 } // function yydev_phone_btn_checkbox_isset($error) {
67
68 // ================================================
69 // Echoing Message if it's exists
70 // ================================================
71
72 function yydev_phone_btn_echo_success_message_if_exists($success) {
73
74 if(isset($success) && !empty($success) ) {
75 echo "<div class='output-messsage'> " . htmlentities($success) . " </div>";
76 } // if(isset($success) && !empty($success) ) {
77
78 } // function yydev_phone_btn_echo_success_message_if_exists($success) {
79
80 function yydev_phone_btn_echo_error_message_if_exists($error) {
81
82 if(isset($error) && !empty($error) ) {
83 echo "<div class='error-messsage'><b>Error:</b> " . $error . " </div>";
84 } // if(isset($_GET['error-message'])) {
85
86 } // function yydev_phone_btn_echo_error_message_if_exists() {
87
88 // ================================================
89 // Echoing Message if it's exists
90 // ================================================
91
92 function yydev_phone_btn_find_page_id() {
93
94 global $wpdb;
95 $post_id_num = 0;
96
97 // in case of page or blog post
98 if( is_single() || is_page() ) {
99 $post_id_num = get_the_ID();
100 } // if( is_single() || is_page() ) {
101
102 // in case of static home page
103 if( is_home() ) {
104 $blog_page_id = get_option( 'page_for_posts' );
105
106 // incase the blog is on the home page
107 if( !empty($blog_page_id) ) {
108 $post_id_num = $blog_page_id;
109 } // if( $blog_page_id ) {
110
111 } // if( !empty($blog_page_id) ) {
112
113 return intval($post_id_num);
114
115 } // function yydev_phone_btn_find_page_id() {
116
117 // ==================================================================
118 // redirect the page using the path you provided
119 // ==================================================================
120
121 function yydev_phone_btn_redirections_page($link) {
122 header("Location: {$link}");
123 exit;
124 } // function yydev_phone_btn_redirections_page($path) {
125