function smooth_slider_media_lib_save($post, $attachment){
global $smooth_slider;
if (current_user_can( $smooth_slider['user_level'] )) {
	global $wpdb, $table_prefix;
	$table_name = $table_prefix.SLIDER_TABLE;
	$post_id=$post['ID'];
	
	if(isset($attachment['slider']) and !isset($attachment['slider_name'])) {
	  $slider_id = '1';
	  if(is_post_on_any_slider($post_id)){
	     $sql = "DELETE FROM $table_name where post_id = '$post_id'";
		 $wpdb->query($sql);
	  }
	  
	  if(isset($attachment['slider']) and $attachment['slider'] == "slider" and !slider($post_id,$slider_id)) {
		$dt = date('Y-m-d H:i:s');
		$sql = "INSERT INTO $table_name (post_id, date, slider_id) VALUES ('$post_id', '$dt', '$slider_id')";
		$wpdb->query($sql);
	  }
	}
	if(isset($attachment['slider']) and $attachment['slider'] == "slider" and isset($attachment['slider_name'])){
	  $slider_id_arr = $attachment['slider_name'];
	  $post_sliders_data = ss_get_post_sliders($post_id);
	  
	  foreach($post_sliders_data as $post_slider_data){
		if(!in_array($post_slider_data['slider_id'],$slider_id_arr)) {
		  $sql = "DELETE FROM $table_name where post_id = '$post_id'";
		  $wpdb->query($sql);
		}
	  }
    
		foreach($slider_id_arr as $slider_id) {
			if(!slider($post_id,$slider_id)) {
				$dt = date('Y-m-d H:i:s');
				$sql = "INSERT INTO $table_name (post_id, date, slider_id) VALUES ('$post_id', '$dt', '$slider_id')";
				$wpdb->query($sql);
			}
		}
	}
	
	$sslider_link = get_post_meta($post_id,'slide_redirect_url',true);
	$link=$attachment['sslider_link'];
	//if(!isset($link) or empty($link) ){$link=get_attachment_link($post_id);} //from 2.3.3
	if($sslider_link != $link and isset($link) and !empty($link)) {
	  update_post_meta($post_id, 'slide_redirect_url', $link);	
	}
	
	$sslider_nolink = get_post_meta($post_id,'sslider_nolink',true);
	if($sslider_nolink != $attachment['sslider_nolink']) {
	  update_post_meta($post_id, 'sslider_nolink', $attachment['sslider_nolink']);	
	}
}	
	return $post;	
} 
Example #2
0
function smooth_slider_media_lib_save($post, $attachment)
{
    global $wp_version;
    if (version_compare($wp_version, '3.5', '<')) {
        // Using WordPress less than 3.5
        global $smooth_slider;
        if (current_user_can($smooth_slider['user_level'])) {
            global $wpdb, $table_prefix;
            $table_name = $table_prefix . SLIDER_TABLE;
            $post_id = $post['ID'];
            if (isset($attachment['slider']) and !isset($attachment['slider_name'])) {
                $slider_id = '1';
                if (is_post_on_any_slider($post_id)) {
                    $wpdb->delete($table_name, array('post_id' => $post_id), array('%d'));
                }
                if (isset($attachment['slider']) and $attachment['slider'] == "slider" and !slider($post_id, $slider_id)) {
                    $dt = date('Y-m-d H:i:s');
                    $wpdb->query($wpdb->prepare("INSERT INTO {$table_name}\r\n\t\t\t\t(post_id, date, slider_id)\r\n\t\t\t\tVALUES ( %d, %s, %d )", $post_id, $dt, $slider_id));
                }
            }
            if (isset($attachment['slider']) and $attachment['slider'] == "slider" and isset($attachment['slider_name'])) {
                $slider_id_arr = $attachment['slider_name'];
                $post_sliders_data = ss_get_post_sliders($post_id);
                foreach ($post_sliders_data as $post_slider_data) {
                    if (!in_array($post_slider_data['slider_id'], $slider_id_arr)) {
                        $wpdb->delete($table_name, array('post_id' => $post_id), array('%d'));
                    }
                }
                foreach ($slider_id_arr as $slider_id) {
                    if (!slider($post_id, $slider_id)) {
                        $dt = date('Y-m-d H:i:s');
                        $wpdb->query($wpdb->prepare("INSERT INTO {$table_name}\r\n\t\t\t\t\t\t(post_id, date, slider_id)\r\n\t\t\t\t\t\tVALUES ( %d, %s, %d )", $post_id, $dt, $slider_id));
                    }
                }
            }
            $sslider_link = get_post_meta($post_id, 'slide_redirect_url', true);
            $link = $attachment['sslider_link'];
            //if(!isset($link) or empty($link) ){$link=get_attachment_link($post_id);} //from 2.3.3
            if ($sslider_link != $link and isset($link) and !empty($link)) {
                update_post_meta($post_id, 'slide_redirect_url', $link);
            }
            $sslider_nolink = get_post_meta($post_id, 'sslider_nolink', true);
            if ($sslider_nolink != $attachment['sslider_nolink']) {
                update_post_meta($post_id, 'sslider_nolink', $attachment['sslider_nolink']);
            }
        }
    }
    //less than WP 3.5
    return $post;
}
Example #3
0
function add_to_slider_checkbox()
{
    global $post, $smooth_slider;
    if (current_user_can($smooth_slider['user_level'])) {
        $extra = "";
        $post_id = $post->ID;
        if (isset($post->ID)) {
            $post_id = $post->ID;
            if (is_post_on_any_slider($post_id)) {
                $extra = 'checked="checked"';
            }
        }
        $post_slider_arr = array();
        $post_sliders = ss_get_post_sliders($post_id);
        if ($post_sliders) {
            foreach ($post_sliders as $post_slider) {
                $post_slider_arr[] = $post_slider['slider_id'];
            }
        }
        $sliders = ss_get_sliders();
        $sslider_link = get_post_meta($post_id, 'slide_redirect_url', true);
        $sslider_nolink = get_post_meta($post_id, 'sslider_nolink', true);
        $thumbnail_key = $smooth_slider['img_pick'][1];
        $sslider_thumbnail = get_post_meta($post_id, $thumbnail_key, true);
        $sslider_disable_image = get_post_meta($post_id, '_disable_image', true);
        $smooth_embed_shortcode = get_post_meta($post_id, '_smooth_embed_shortcode', true);
        ?>
	
	  <?php 
        /* start tab 2.6 */
        ?>
	
             <script type="text/javascript">
		jQuery(document).ready(function($) {
			jQuery("#smooth_basic").css({"background":"#222222","color":"#ffffff"});
			jQuery("#smooth_basic").on("click", function(){ 
				jQuery("#smooth_basic_tab").fadeIn("fast");
				jQuery("#smooth_advaced_tab").fadeOut("fast");
				jQuery(this).css({"background":"#222222","color":"#ffffff"});
				jQuery("#smooth_advanced").css({"background":"buttonface","color":"#222222"});
			});
			jQuery("#smooth_advanced").on("click", function(){
				jQuery("#smooth_basic_tab").fadeOut("fast");
				jQuery("#smooth_advaced_tab").fadeIn("fast");
				jQuery(this).css({"background":"#222222","color":"#ffffff"});
				jQuery("#smooth_basic").css({"background":"buttonface","color":"#222222"});
				
			});
		}); 
		</script>
	    <?php 
        /* End tab 2.6 */
        ?>
	<div style="border-bottom: 1px solid #ccc;padding-bottom: 0;padding-left: 10px;">
		<button type="button" id="smooth_basic" style="padding:5px 30px 5px 30px;margin: 0;cursor:pointer;border:0;outline:none;">Basic</button>
		<button type="button" id="smooth_advanced" style="padding:5px 30px 5px 30px;margin:0 0 0 10px;cursor:pointer;border:0;outline:none">Advanced</button>
		</div>
	<div id="smooth_basic_tab">
		<div id="slider_checkbox">
		<table class="form-table">
		<tr valign="top">
		<th scope="row"><input type="checkbox" class="sldr_post" name="slider" value="slider" <?php 
        echo $extra;
        ?>
 />
		<label for="slider"><?php 
        _e('Add this post/page to', 'smooth-slider');
        ?>
 </label></th>
		<td><select name="slider_name[]" multiple="multiple" size="2" style="height:4em;">
                <?php 
        foreach ($sliders as $slider) {
            ?>
                  <option value="<?php 
            echo $slider['slider_id'];
            ?>
" <?php 
            if (in_array($slider['slider_id'], $post_slider_arr)) {
                echo 'selected';
            }
            ?>
><?php 
            echo $slider['slider_name'];
            ?>
</option>
                <?php 
        }
        ?>
                </select></td></tr>
	
	<tr valign="top">
		 <th scope="row"><label for="sslider_link"><?php 
        _e('Slide Link URL ', 'smooth-slider');
        ?>
</label></th>
                <td><input type="text" name="sslider_link" class="sslider_link" value="<?php 
        echo $sslider_link;
        ?>
" size="50" /><small><?php 
        _e('If left empty, it will be by default linked to the permalink.', 'smooth-slider');
        ?>
</small> </td></tr>
                
	<tr valign="top">
		 <th scope="row"><label for="sslider_nolink"> <?php 
        _e('Do not link this slide to any page(url)', 'smooth-slider');
        ?>
</label></th>
                <td><input type="checkbox" name="sslider_nolink" class="sslider_nolink" value="1" <?php 
        if ($sslider_nolink == '1') {
            echo "checked";
        }
        ?>
  /> </td></tr>
		</table>
                  </div>
	</div>
	<div id="smooth_advaced_tab" style="display:none;">   
		<div class="slider_checkbox">
		<table class="form-table">
            <?php 
        if ($smooth_slider['multiple_sliders'] == '1') {
            ?>
                <tr valign="top">
		<th scope="row"><label for="display_slider"><?php 
            _e('Display ', 'smooth-slider');
            ?>
		<select name="display_slider_name">
                <?php 
            foreach ($sliders as $slider) {
                ?>
                  <option value="<?php 
                echo $slider['slider_id'];
                ?>
" <?php 
                if (ss_post_on_slider($post_id, $slider['slider_id'])) {
                    echo 'selected';
                }
                ?>
><?php 
                echo $slider['slider_name'];
                ?>
</option>
                <?php 
            }
            ?>
                </select><?php 
            _e('on this Post/Page', 'smooth-slider');
            ?>
</th> 
		<td><input type="checkbox" class="sldr_post" name="display_slider" value="1" <?php 
            if (ss_slider_on_this_post($post_id)) {
                echo "checked";
            }
            ?>
 /><?php 
            _e('(Add the Smooth Slider template tag manually on your page.php/single.php or whatever page template file)');
            ?>
</label></td></tr>
          <?php 
        }
        ?>
		  
		<tr valign="top">
		 <th scope="row"><label for="_smooth_slider_style"><?php 
        _e('Stylesheet to use if slider is displayed on this Post/Page', 'smooth-slider');
        ?>
 </label></th>
    <?php 
        $slider_style = get_post_meta($post->ID, '_smooth_slider_style', true);
        ?>
        <td> <select name="_smooth_slider_style" >
			<?php 
        $directory = SMOOTH_SLIDER_CSS_DIR;
        if ($handle = opendir($directory)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != '.' and $file != '..') {
                    ?>
                  <option value="<?php 
                    echo $file;
                    ?>
" <?php 
                    if ($slider_style == $file or empty($slider_style) and $smooth_slider['stylesheet'] == $file) {
                        echo "selected";
                    }
                    ?>
 ><?php 
                    echo $file;
                    ?>
</option>
             <?php 
                }
            }
            closedir($handle);
        }
        ?>
        </select> </td></tr>
          
	<input type="hidden" name="sldr-verify" id="sldr-verify" value="<?php 
        echo wp_create_nonce('SmoothSlider');
        ?>
" />
	   	 <tr valign="top">
		 <th scope="row"><label for="sslider_thumbnail"><?php 
        _e('Custom Thumbnail Image(url)', 'smooth-slider');
        ?>
</label></th>
                	<td><input type="text" name="sslider_thumbnail" class="sslider_thumbnail" value="<?php 
        echo $sslider_thumbnail;
        ?>
" size="50" />
                </td></tr>
		<tr valign="top">
		<th scope="row"><label for="disable_image"><?php 
        _e('Disable Thumbnail Image', 'smooth-slider');
        ?>
 </label></th>
		<td><input type="checkbox" name="disable_image" value="1" <?php 
        if ($sslider_disable_image == '1') {
            echo "checked";
        }
        ?>
  /> </td>
		</tr>
              
                
		<!-- Added for video - Start -->
		<tr valign="top">
		<th scope="row"><label for="embed_shortcode"><?php 
        _e('Embed Shortcode', 'smooth-slider');
        ?>
 </label><br><br><div style="font-weight:normal;border:1px dashed #ccc;padding:5px;color:#666;line-height:20px;font-size:13px;">You can embed any type of shortcode e.g video shortcode or button shortcode which you want to be overlaid on the slide.</div></th>
		<td><textarea rows="4" cols="50" name="smooth_sslider_eshortcode"><?php 
        echo htmlentities($smooth_embed_shortcode, ENT_QUOTES);
        ?>
</textarea></td>
		</tr>
		</table>
		<!-- Added for video - End -->

                 </div>
    </div>
        
<?php 
    }
}
function add_to_slider_checkbox()
{
    global $post, $smooth_slider;
    if (current_user_can($smooth_slider['user_level'])) {
        $extra = "";
        $post_id = $post->ID;
        if (isset($post->ID)) {
            $post_id = $post->ID;
            if (is_post_on_any_slider($post_id)) {
                $extra = 'checked="checked"';
            }
        }
        $post_slider_arr = array();
        $post_sliders = ss_get_post_sliders($post_id);
        if ($post_sliders) {
            foreach ($post_sliders as $post_slider) {
                $post_slider_arr[] = $post_slider['slider_id'];
            }
        }
        $sliders = ss_get_sliders();
        ?>

		<div id="slider_checkbox">
				<input type="checkbox" class="sldr_post" name="slider" value="slider" <?php 
        echo $extra;
        ?>
 />
				<label for="slider">Add this post/page to </label>
				<select name="slider_name[]" multiple="multiple" size="2" style="height:4em;">
                <?php 
        foreach ($sliders as $slider) {
            ?>

                  <option value="<?php 
            echo $slider['slider_id'];
            ?>
" <?php 
            if (in_array($slider['slider_id'], $post_slider_arr)) {
                echo 'selected';
            }
            ?>
><?php 
            echo $slider['slider_name'];
            ?>
</option>
                <?php 
        }
        ?>

                </select>
                
         <?php 
        if ($smooth_slider['multiple_sliders'] == '1') {
            ?>

                <br />
                <br />
                <br />
                
                <input type="checkbox" class="sldr_post" name="display_slider" value="1" <?php 
            if (ss_slider_on_this_post($post_id)) {
                echo "checked";
            }
            ?>
 />
				<label for="display_slider">Display 
				<select name="display_slider_name">
                <?php 
            foreach ($sliders as $slider) {
                ?>

                  <option value="<?php 
                echo $slider['slider_id'];
                ?>
" <?php 
                if (ss_post_on_slider($post_id, $slider['slider_id'])) {
                    echo 'selected';
                }
                ?>
><?php 
                echo $slider['slider_name'];
                ?>
</option>
                <?php 
            }
            ?>

                </select> on this Post/Page (you need to add the Smooth Slider template tag manually on your page.php/single.php or whatever page template file)</label>
          <?php 
        }
        ?>

          
				<input type="hidden" name="sldr-verify" id="sldr-verify" value="<?php 
        echo wp_create_nonce('SmoothSlider');
        ?>
" />
	    </div>
        <br />
        <div>
        <?php 
        $slider_style = get_post_meta($post->ID, 'slider_style', true);
        ?>

         <select name="slider_style" >
			<?php 
        $directory = WP_PLUGIN_DIR . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__)) . '/css/styles/';
        if ($handle = opendir($directory)) {
            while (false !== ($file = readdir($handle))) {
                if ($file != '.' and $file != '..') {
                    ?>

                  <option value="<?php 
                    echo $file;
                    ?>
" <?php 
                    if ($slider_style == $file) {
                        echo "selected";
                    }
                    ?>
 ><?php 
                    echo $file;
                    ?>
</option>
             <?php 
                }
            }
            closedir($handle);
        }
        ?>

        </select> <label for="slider_style">Stylesheet to use if slider is displayed on this Post/Page </label><br /> <br />
        
  <?php 
        $thumbnail_key = $smooth_slider['img_pick'][1];
        $sslider_thumbnail = get_post_meta($post_id, $thumbnail_key, true);
        $sslider_link = get_post_meta($post_id, 'slide_redirect_url', true);
        $sslider_nolink = get_post_meta($post_id, 'sslider_nolink', true);
        ?>

                <label for="sslider_thumbnail">Custom Thumbnail Image(url)
                <input type="text" name="sslider_thumbnail" class="sslider_thumbnail" value="<?php 
        echo $sslider_thumbnail;
        ?>
" size="75" />
                <br /> </label> <br /><br />
                <fieldset>
                <label for="sslider_link">Slide Link URL 
                <input type="text" name="sslider_link" class="sslider_link" value="<?php 
        echo $sslider_link;
        ?>
" size="50" /> </label>
                <label for="sslider_nolink"> 
                <input type="checkbox" name="sslider_nolink" class="sslider_nolink" value="1" <?php 
        if ($sslider_nolink == '1') {
            echo "checked";
        }
        ?>
  /> Do not link this slide to any page(url)</label>
                 </fieldset>
                 </div>
        
<?php 
    }
}