| Server IP : 60.247.133.247 / Your IP : 216.73.217.108 Web Server : Apache System : Linux ebs-119054 5.10.0-14-amd64 #1 SMP Debian 5.10.113-1 (2022-04-29) x86_64 User : goodwill ( 65985) PHP Version : 8.2.20 Disable Function : link,symlink,passthru,exec,system,shell_exec,proc_open,popen,pcntl_exec,socket_bind,stream_socket_server,pcntl_fork,pcntl_rfork MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/wwwroot/goodwill/wwwroot/wp-content/plugins/js_composer/include/autoload/ |
Upload File : |
<?php
/**
* Autoload hooks and ajax actions related to single image.
*
* @note we require our autoload files everytime and everywhere after plugin load.
*/
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
if ( 'vc_edit_form' === vc_post_param( 'action' ) ) {
add_filter( 'vc_edit_form_fields_attributes_vc_single_image', 'vc_single_image_convert_old_link_to_new' );
}
/**
* Backward compatibility
*
* @param array $atts
* @return mixed
* @since 4.6
*/
function vc_single_image_convert_old_link_to_new( $atts ) {
if ( empty( $atts['onclick'] ) && isset( $atts['img_link_large'] ) && 'yes' === $atts['img_link_large'] ) {
$atts['onclick'] = 'img_link_large';
unset( $atts['img_link_large'] );
} elseif ( empty( $atts['onclick'] ) && ( ! isset( $atts['img_link_large'] ) || 'yes' !== $atts['img_link_large'] ) ) {
unset( $atts['img_link_large'] );
}
if ( empty( $atts['onclick'] ) && ! empty( $atts['link'] ) ) {
$atts['onclick'] = 'custom_link';
}
return $atts;
}
add_action( 'wp_ajax_wpb_single_image_src', 'vc_single_image_src' );
/**
* Get Single Image source URL.
*/
function vc_single_image_src() {
vc_user_access()->checkAdminNonce()->validateDie()->wpAny( 'edit_posts', 'edit_pages' )->validateDie();
$image_id = (int) vc_post_param( 'content' );
$params = vc_post_param( 'params' );
$post_id = (int) vc_post_param( 'post_id' );
$img_size = vc_post_param( 'size' );
if ( ! empty( $params['source'] ) ) {
$source = $params['source'];
} else {
$source = 'media_library';
}
$image_data = wpb_get_image_data_by_source( $source, $post_id, $image_id, $img_size );
echo esc_url( $image_data['image_src'] );
die();
}
add_action( 'wp_ajax_wpb_single_image_data', 'vc_single_image_data' );
/**
* Get single image data (source URL, alt attribute).
*
* @since 7.4
*/
function vc_single_image_data() {
vc_user_access()->checkAdminNonce()->validateDie()->wpAny( 'edit_posts', 'edit_pages' )->validateDie();
$image_id = (int) vc_post_param( 'content' );
$params = vc_post_param( 'params' );
$post_id = (int) vc_post_param( 'post_id' );
$img_size = vc_post_param( 'size' );
if ( ! empty( $params['source'] ) ) {
$source = $params['source'];
} else {
$source = 'media_library';
}
$image_data = wpb_get_image_data_by_source( $source, $post_id, $image_id, $img_size );
wp_send_json_success( $image_data );
}