| 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_accessibility_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_accessibility_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_accessibility_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_accessibility_show_error_message($error) { |
| 50 |
|
| 51 |
|
| 52 |
// ================================================================== |
| 53 |
// Cehcking if the checkbox is already set |
| 54 |
// ================================================================== |
| 55 |
|
| 56 |
function yydev_accessibility_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_accessibility_checkbox_isset($error) { |
| 67 |
|
| 68 |
// ================================================ |
| 69 |
// Echoing Message if it's exists |
| 70 |
// ================================================ |
| 71 |
|
| 72 |
function yydev_accessibility_echo_message_if_exists() { |
| 73 |
|
| 74 |
if(isset($_GET['message'])) { |
| 75 |
echo "<div class='output-messsage'> " . htmlentities($_GET['message']) . " </div>"; |
| 76 |
} // if(isset($_GET['message'])) { |
| 77 |
|
| 78 |
if(isset($_GET['error-message'])) { |
| 79 |
echo "<div class='error-messsage'><b>Error:</b> " . htmlentities($_GET['error-message']) . " </div>"; |
| 80 |
} // if(isset($_GET['error-message'])) { |
| 81 |
|
| 82 |
} // function yydev_accessibility_echo_message_if_exists() { |
| 83 |
|
| 84 |
|
| 85 |
function yydev_accessibility_echo_success_message_if_exists($success) { |
| 86 |
|
| 87 |
if(isset($success) && !empty($success) ) { |
| 88 |
echo "<div class='output-messsage'> " . htmlentities($success) . " </div>"; |
| 89 |
} // if(isset($success) && !empty($success) ) { |
| 90 |
|
| 91 |
} // function yydev_accessibility_echo_success_message_if_exists($success) { |
| 92 |
|
| 93 |
function yydev_accessibility_echo_error_message_if_exists($error) { |
| 94 |
|
| 95 |
if(isset($error) && !empty($error) ) { |
| 96 |
echo "<div class='error-messsage'><b>Error:</b> " . $error . " </div>"; |
| 97 |
} // if(isset($_GET['error-message'])) { |
| 98 |
|
| 99 |
} // function yydev_accessibility_echo_error_message_if_exists() { |
| 100 |
|
| 101 |
// ================================================ |
| 102 |
// Echoing Message if it's exists |
| 103 |
// ================================================ |
| 104 |
|
| 105 |
function yydev_accessibility_find_page_id() { |
| 106 |
|
| 107 |
global $wpdb; |
| 108 |
$post_id_num = 0; |
| 109 |
|
| 110 |
// in case of page or blog post |
| 111 |
if( is_single() || is_page() ) { |
| 112 |
$post_id_num = get_the_ID(); |
| 113 |
} // if( is_single() || is_page() ) { |
| 114 |
|
| 115 |
// in case of static home page |
| 116 |
if( is_home() ) { |
| 117 |
$blog_page_id = get_option( 'page_for_posts' ); |
| 118 |
|
| 119 |
// incase the blog is on the home page |
| 120 |
if( !empty($blog_page_id) ) { |
| 121 |
$post_id_num = $blog_page_id; |
| 122 |
} // if( $blog_page_id ) { |
| 123 |
|
| 124 |
} // if( !empty($blog_page_id) ) { |
| 125 |
|
| 126 |
return intval($post_id_num); |
| 127 |
|
| 128 |
} // function yydev_accessibility_find_page_id() { |
| 129 |
|
| 130 |
// ================================================================== |
| 131 |
// redirect the page using the path you provided |
| 132 |
// ================================================================== |
| 133 |
|
| 134 |
function yydev_accessibility_redirections_page($link) { |
| 135 |
header("Location: {$link}"); |
| 136 |
exit; |
| 137 |
} // function yydev_accessibility_redirections_page($path) { |
| 138 |
|