| Server IP : 52.25.153.185 / Your IP : 216.73.217.131 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-35-cloud-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/testify/includes/ |
Upload File : |
<?php
/*
* This file modified by Dominika Rauk, Jonathan Hall, and/or others; last modified 2020-08-28
*/
if (!defined('ABSPATH')) die();
global $testify_meta_box;
$testify_meta_box = array(
'id' => 'testify-meta',
'title' => __('Testify', 'testify-testify'),
'page' => 'testify-testimonial',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'id' => 'testimonial-author',
'name' => __('Testimonial Author:', 'testify-testify'),
'type' => 'text',
'std' => ''
),
array(
'id' => 'testimonial-author-link',
'name' => __('Author\'s website:', 'testify-testify'),
'type' => 'url',
'std' => ''
),
array(
'id' => 'testimonial-author-position',
'name' => __('Author\'s position:', 'testify-testify'),
'type' => 'text',
'std' => ''
),
array(
'id' => 'testimonial-rating',
'name' => __('Rating:', 'testify-testify'),
'type' => 'number',
'min' => 0,
'max' => 5,
'step' => 0.1,
'std' => ''
),
));
function testify_add_box( $hook ) {
global $testify_meta_box;
add_meta_box($testify_meta_box['id'], $testify_meta_box['title'], 'testify_show_box', $testify_meta_box['page'], $testify_meta_box['context'], $testify_meta_box['priority']);
if ( $hook != 'testify-testimonial' ) {
add_meta_box( 'testify_font_templates', 'testify_font_templates', 'testify_font_templates' );
}
}
add_action('add_meta_boxes', 'testify_add_box');
function testify_font_templates() {
// Google Fonts Template
printf(
'<script type="text/template" id="testify-google-fonts-options-items">
%1$s
</script>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- this function returns escaped HTML
testify_get_font_options_items()
);
// Font Icons Template
printf(
'<script type="text/template" id="testify-font-icon-list-items">
%1$s
</script>',
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- this function returns escaped HTML
testify_get_font_icon_list_items()
);
}
// Callback function to display fields in meta box
function testify_show_box( $hook ) {
global $testify_meta_box, $post;
/*<!--Nonce verification--> */
wp_nonce_field( 'testify_save_data', 'testify_meta_box_nonce' );
?>
<?php
$testimonialSubmitTime = get_post_meta($post->ID, 'testimonial-submit-time', true);
if (!empty($testimonialSubmitTime)) {
$testimonialSubmitEmail = get_post_meta($post->ID, 'testimonial-submit-email', true);
echo sprintf(
esc_html__('%1s Submitted at %2s on %3s by %4s (%5s)%6s', 'testify-testify' ),
'<p>',
esc_html( gmdate(get_option('time_format'), $testimonialSubmitTime) ),
esc_html( gmdate(get_option('date_format'), $testimonialSubmitTime) ),
'<a href="mailto:'.esc_html($testimonialSubmitEmail).'">'.esc_html($testimonialSubmitEmail).'</a>',
esc_html( get_post_meta($post->ID, 'testimonial-submit-ip', true) ),
'</p>'
);
}
?>
<table class="form-table">
<?php
foreach ($testify_meta_box['fields'] as $field) {
// get current post meta data
$meta = get_post_meta($post->ID, $field['id'], true);
?>
<tr>
<th><label for="<?php echo esc_attr($field['id']); ?>"> <?php echo esc_html($field['name']); ?></label></th>
<td>
<?php
switch ($field['type']) {
case 'text':
?>
<input type="text" name="<?php echo esc_attr($field['id']); ?>" id="<?php echo esc_attr($field['id']); ?>" value="<?php echo esc_attr($meta ? $meta : $field['std']); ?>" size="30" />
<?php
break;
case 'url':
?>
<input type="url" name="<?php echo esc_attr($field['id']); ?>" id="<?php echo esc_attr($field['id']); ?>" value="<?php echo esc_attr($meta ? $meta : $field['std']); ?>" size="50" />
<?php
break;
case 'number':
?>
<input type="number" min="<?php echo (int) $field['min'] ?>" max="<?php echo (int) $field['max'] ?>" step="<?php echo (float) $field['step'] ?>" name="<?php echo esc_attr($field['id']); ?>" id="<?php echo esc_attr($field['id']); ?>" value="<?php echo esc_attr($meta ? $meta : $field['std']); ?>" size="18" />
<?php
break;
}
} ?>
</table>
<?php
}
// Save data from meta box
function testify_save_data($post_id) {
global $testify_meta_box;
// verify nonce
// Check if our nonce is set.
if ( ! isset( $_POST['testify_meta_box_nonce'] ) ) {
return;
}
// Verify that the nonce is valid.
if ( ! wp_verify_nonce( sanitize_text_field( $_POST['testify_meta_box_nonce'] ), 'testify_save_data' ) ) {
return;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
// check permissions
if (!empty($_POST['post_type']) && 'page' == $_POST['post_type']) {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($testify_meta_box['fields'] as $field) {
$old = get_post_meta($post_id, $field['id'], true);
if ( isset($_POST[$field['id']]) ) {
switch ($field['type']) {
case 'url':
$new = esc_url_raw($_POST[$field['id']]);
break;
case 'number':
$value = round(floatval( $_POST[$field['id']] ), 1, PHP_ROUND_HALF_UP);
empty($value) || $value < 0 || $value > 5 ? $new = '' : $new = $value;
break;
default:
$new = sanitize_text_field( $_POST[$field['id']] );
}
} else {
$new = '';
}
if ($new && $new != $old) {
update_post_meta($post_id, $field['id'], $new);
} elseif ('' == $new && $old) {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
add_action('save_post', 'testify_save_data');
?>