'; } return $form_action_url; } function rs_admin_enqueue_scripts( $hook ) { wp_enqueue_script('thickbox'); if( isset($_REQUEST['newrs-a-gallery-enabled']) && $_REQUEST['newrs-a-gallery-enabled'] ) { wp_register_style( "royalslider-admin", NEW_ROYALSLIDER_PLUGIN_URL . "lib/backend/royalslider-admin.css", array( ), NEW_ROYALSLIDER_WP_VERSION, 'screen' ); wp_enqueue_style( "royalslider-admin" ); wp_register_script( 'new-rs-toJSON', NEW_ROYALSLIDER_PLUGIN_URL . 'lib/backend/toJSON.js', array('jquery')); wp_enqueue_script( 'new-rs-toJSON' ); wp_register_script( 'new-royalslider-gallery-js', NEW_ROYALSLIDER_PLUGIN_URL . 'lib/backend/royalslider-gallery.js', array('jquery')); wp_localize_script( 'new-royalslider-gallery-js', 'rsMediaAddVars', array( 'enabled' => true, 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'getImagesNonce' => wp_create_nonce( 'new_royalslider_get_images_ajax_nonce' ), 'getSingleImageNonce' => wp_create_nonce( 'new_royalslider_get_image_ajax_nonce' ), 'add_to_slider' => __('Add to slider', 'new_royalslider'), 'add_all_uploaded_to_slider' => __('Add all uploaded to slider', 'new_royalslider'), 'add' => __('Add all ', 'new_royalslider'), 'images_to_slider' => __(' images to slider', 'new_royalslider'), 'add_to_slider_singular' => __('Add one image to slider', 'new_royalslider'), 'adding' => __('Adding...', 'new_royalslider'), 'added' => __('Added!', 'new_royalslider'), 'isSingle' => isset($_REQUEST['newrs-a-gallery-single']) && $_REQUEST['newrs-a-gallery-single'] )); wp_enqueue_script('new-royalslider-gallery-js'); } } function rs_create_new_slide() { check_ajax_referer('new_royalslider_new_admin_slide_nonce'); echo self::get_admin_slide_item(null); die(); } function rs_get_custom_media() { check_ajax_referer('new_royalslider_get_images_ajax_nonce'); foreach($_POST['attachments'] as $key => $attachment_id) { $image_post = get_post( $attachment_id ); $slide_data = array( 'image' => array( 'attachment_id' => $attachment_id ), 'title' => $image_post->post_title, 'description' => $image_post->post_excerpt ); echo self::get_admin_slide_item($slide_data); } die(); } function rs_get_single_media() { check_ajax_referer('new_royalslider_get_image_ajax_nonce'); foreach($_POST['attachments'] as $key => $attachment_id) { $image_src = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); $large_src = wp_get_attachment_image_src( $attachment_id, 'large' ); $image_post = get_post( $attachment_id ); $imagedata = array( 'id' => $attachment_id, 'src' => $image_src[0], 'title' => $image_post->post_title, 'caption' => $image_post->post_excerpt, 'large' => $large_src[0], 'large_width' => $large_src[1], 'large_height'=> $large_src[2] ); echo json_encode( $imagedata ); } die(); } static function get_admin_slide_item($slide_data) { $image_src = ''; if( isset($slide_data['image']) ) { $image_data = $slide_data['image']; if(isset($image_data['attachment_id'])) { $image_src = wp_get_attachment_image_src( $image_data['attachment_id'], 'thumbnail' ); $image_src = $image_src[0]; } } else if(isset($slide_data['video']) && isset($slide_data['video']['thumb']) ) { $image_src = $slide_data['video']['thumb']; } if(!$image_src) { $image_src = NEW_ROYALSLIDER_PLUGIN_URL . 'lib/backend/img/empty150.png'; } $out = '
%s
%s
'; return sprintf( $out, $image_src, __('Remove slide', 'new_royalslider'), __('Edit slide', 'new_royalslider'), __('Duplicate slide', 'new_royalslider'), self::getImageTab($slide_data, $image_src), isset($slide_data['animated_blocks']) ? $slide_data['animated_blocks'] : '', self::getHTMLTab($slide_data) ); return $out; } static function getHTMLTab($slide_data) { $out = ''; $out .= ''; return $out; } static function getImageTab($slide_data, $image_src) { $out = ''; $attachment_id = ''; $big_image = ''; $big_image_src = ''; $image_data = ''; if(isset($slide_data['image'])) { $image_data = $slide_data['image']; if(isset($slide_data['image']['attachment_id'])) { $attachment_id = $slide_data['image']['attachment_id']; $big_image = wp_get_attachment_image_src( $attachment_id, 'large' ); $big_image_src = $big_image[0]; } } $add_label = $image_data ? __('Change image', 'new_royalslider') : __('Add image', 'new_royalslider'); $hidden = !$image_data ? 'style="display:none"' : ''; $out .= '
'. $add_label .' '. __('Remove image', 'new_royalslider') .'
'; $out .= '
'; $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'title', 'label' => __( 'Title & alt ', 'new_royalslider' ), 'desc' => __( 'Title of the slide. Alt tag of image. Caption. (by default).
In Slide Markup Editor use {{title}} to get value of this field.', 'new_royalslider' ), 'type' => 'text', 'default' => isset($slide_data['title']) ? $slide_data['title'] : '' ),'slides' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'description', 'label' => __( 'Description ', 'new_royalslider' ), 'desc' => __( 'Short description of slide, used by some templates (like content slider).
In Slide Markup Editor use {{description}}} to get value of this field.', 'new_royalslider' ), 'type' => 'textarea', 'default' => isset($slide_data['description']) ? $slide_data['description'] : '' ),'slides' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'link', 'label' => __( 'Link ', 'new_royalslider' ), 'desc' => __( 'Links whole slide to URL in this field.
Please note that full slide link doesn\'t work with auto-height option and overlays video. You can edit Slide Markup to link just specific button or image by wrapping it with "a" HTML tag .
In Slide Markup Editor use {{link_url}} to get value of this field.', 'new_royalslider' ), 'type' => 'text', 'default' => isset($slide_data['link']) ? $slide_data['link'] : '' ),'slides' ); $out .= '
'; if( !isset($slide_data['video']) ) { $video_data = array( 'url' => '', 'thumb' => '', 'image' => '' ); } else { $video_data = $slide_data['video']; } $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'url', 'label' => __( 'YouTube or Vimeo video URL ', 'new_royalslider' ), 'desc' => __( 'Link to YouTube or Vimeo video page. In formats like:
vimeo.com/123123
www.youtube.com/watch?v=7iIld0Z_wlc
youtu.be/7iIld0Z_wlc
In Slide Markup Editor use {{video_url}} to get value of this field.', 'new_royalslider' ), 'type' => 'text', 'default' => $video_data['url'] ),'slides[video]' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'image', 'type' => 'hidden', 'default' => isset($video_data['image']) ? $video_data['image'] : '' ),'slides[video]' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'thumb', 'type' => 'hidden', 'default' => isset($video_data['thumb']) ? $video_data['thumb'] : '' ),'slides[video]' ); $out .= '
'; $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'attachment_id', 'type' => 'hidden', 'default' => $attachment_id ),'slides[image]' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'large', 'type' => 'hidden', 'default' => $big_image_src ),'adminarea' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'large_gen', 'type' => 'hidden', 'default' => $big_image_src ),'adminarea' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'large_width', 'type' => 'hidden', 'default' => $big_image ? $big_image[1] : '' ),'adminarea' ); $out .= NewRoyalSliderOptions::get_field_html( array( 'name' => 'large_height', 'type' => 'hidden', 'default' => $big_image ? $big_image[2] : '' ),'adminarea' ); // allow developers to add instructions or inputs below the form ob_start(); do_action('new_royalslider_image_tab_after_inputs', $slide_data); $out .= ob_get_contents(); ob_end_clean(); $out .= '
'; return $out; } public function add_buttons( $form_fields, $post ) { if(isset($_REQUEST['newrs-a-gallery-enabled'])) { $form_fields['post_content']['value'] = ''; $form_fields['post_content']['input'] = 'hidden'; $form_fields['url']['value'] = ''; $form_fields['url']['input'] = 'hidden'; $form_fields['align']['value'] = 'aligncenter'; $form_fields['align']['input'] = 'hidden'; $form_fields['image-size']['value'] = 'thumbnail'; $form_fields['image-size']['input'] = 'hidden'; $label = isset($_REQUEST['newrs-a-gallery-single']) ? __('Select this image', 'new_royalslider') : __('Add to slider', 'new_royalslider'); $form_fields['dsframework_media_box_add_button'] = array( 'label' => '', 'input' => 'html', 'html' => '', ); } return $form_fields; } public function remove_unused_tab($tabs_to_add) { if(isset($_REQUEST['newrs-a-gallery-enabled'])) { $tabs_to_add = array('type' => 'From Computer', 'library' => 'Media Library'); } return $tabs_to_add; } } endif;