Created
June 17, 2020 15:11
-
-
Save RupW/997dc746305f44aa3de1b4aba82448e6 to your computer and use it in GitHub Desktop.
Fixed up CrossSlide WordPress plugin 1.6.0 for https://wordpress.stackexchange.com/q/369203
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Cross Slide Cross Fade | |
Plugin URI: http://thisismyurl.com/downloads/wordpress-plugins/ | |
Description: Adds the Cross Slide for WordPress effect to websites. | |
Author: Christopher Ross | |
Author URI: http://thisismyurl.com | |
Version: 1.6.0 | |
*/ | |
/* | |
/--------------------------------------------------------------------\ | |
| | | |
| License: GPL | | |
| | | |
| Copyright ( C ) 2011, Christopher Ross | | |
| http://thisismyurl.com | | |
| All rights reserved. | | |
| | | |
| This program is free software; you can redistribute it and/or | | |
| modify it under the terms of the GNU General Public License | | |
| as published by the Free Software Foundation; either version 2 | | |
| of the License, or ( at your option ) any later version. | | |
| | | |
| This program is distributed in the hope that it will be useful, | | |
| but WITHOUT ANY WARRANTY; without even the implied warranty of | | |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | |
| GNU General Public License for more details. | | |
| | | |
| You should have received a copy of the GNU General Public License | | |
| along with this program; if not, write to the | | |
| Free Software Foundation, Inc. | | |
| 51 Franklin Street, Fifth Floor | | |
| Boston, MA 02110-1301, USA | | |
| | | |
\--------------------------------------------------------------------/ | |
*/ | |
add_shortcode( 'Crossslide', 'thisismyurl_wp_crossslide' ); | |
// plugin definitions | |
load_plugin_textdomain( 'csj',false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); | |
register_activation_hook( __FILE__, 'thisismyurl_wp_crossslide_activate' ); | |
function cr_wp_crossslide( ) { | |
// legacy support | |
return thisismyurl_wp_crossslide( ); | |
} | |
function thisismyurl_wp_crossslide( ) { | |
$options = get_option( 'thisismyurl_csj' ); | |
if ( empty( $options ) ) $options = get_option('cr_csj'); | |
$slideshow = $options->slideshow; | |
if ( count( $slideshow ) > 0 ) { | |
foreach ( $slideshow as $header ) { | |
$pics[] = $header; | |
} | |
} | |
$width = $options->crossslideshowwidth; | |
$height = $options->crossslideshowheight; | |
if ( $options->csj_random == 1 ) shuffle( $pics ); | |
foreach ( $pics as $pic ) { | |
$piclist .= "{ src: '".$pic."' },"; | |
if( $count == 0 ) {$first = $pic; $count++;} | |
$kenburns .= "{ | |
src: '".$pic."', | |
alt: '', | |
from: '100% 80% 1x', | |
to: '100% 0% 1.7x', | |
time: ".$options->csj_sleep." | |
},"; | |
} | |
$piclist = substr( $piclist, 0, strlen( $piclist )-1 ); | |
$kenburns = substr( $kenburns, 0, strlen( $kenburns )-1 ); | |
echo "<div style='background=( url:$first ); width: ".$width."px;height:".$height."px;' id='crslideshow'>"; | |
if ( $options->csj_default_jquery == 1 ) echo "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js' type='text/javascript'></script>"; | |
echo "<script src='" . WP_PLUGIN_URL.'/'.str_replace( basename( __FILE__ ),"",plugin_basename( __FILE__ ) ) . "jquery.cross-slide.js' type='text/javascript'></script> "; | |
if ( $options->csj_kenburns != 1 ) { | |
?> | |
<script type="text/javascript"> | |
//<!-- | |
jQuery( function( ){ | |
jQuery( '#crslideshow' ).crossSlide( { | |
sleep: <?php echo $options->csj_sleep; ?>, | |
fade: <?php echo $options->csj_fade; ?> | |
}, [ | |
<?php echo $piclist;?> | |
] ); | |
} ); | |
// --> | |
</script> | |
<?php | |
} else { | |
?> | |
<script type="text/javascript"> | |
jQuery( '#crslideshow' ).crossSlide( { | |
fade: <?php echo $options->csj_fade; ?> | |
}, [ | |
<?php echo $kenburns;?> | |
], function( idx, img, idxOut, imgOut ) { | |
if ( idxOut == undefined ) | |
{ | |
// starting single image phase, put up caption | |
jQuery( 'div.caption' ).text( img.alt ).animate( { opacity: .7 } ) | |
} | |
else | |
{ | |
// starting cross-fade phase, take out caption | |
jQuery( 'div.caption' ).fadeOut( ) | |
} | |
} ); | |
// --> | |
</script> | |
<?php | |
} | |
echo "</div>"; | |
} | |
function thisismyurl_wp_crossslide_activate( ) { | |
$x = WP_PLUGIN_URL.'/'.str_replace( basename( __FILE__ ),"",plugin_basename( __FILE__ ) ); | |
$header[] = $x."slideshow-sample-1.png"; | |
$header[] = $x."slideshow-sample-2.png"; | |
$header[] = $x."slideshow-sample-3.png"; | |
$header[] = $x."slideshow-sample-4.png"; | |
$options->crossslideshowwidth = 800; | |
$options->crossslideshowheight = 200; | |
$options->csj_sleep = 5; | |
$options->csj_fade = 1; | |
$options->slideshow = $header; | |
$options->csj_default_jquery = 1; | |
update_option( 'thisismyurl_csj',$options ); | |
} | |
// add menu to WP admin | |
function thisismyurl_csj_menu( ) {add_management_page( __( 'Cross Slide' ), __( 'Cross Slide' ), 10,'thisismyurl_csj.php', 'thisismyurl_csj_options' );} | |
add_action( 'admin_menu', 'thisismyurl_csj_menu' ); | |
// add a comment to the footer | |
function thisismyurl_csj_footer_code( $options='' ) {echo "<!-- Cross Slide Cross Fade for WordPress by Christopher Ross - http://thisismyurl.com -->";} | |
add_action( 'wp_footer', 'thisismyurl_csj_footer_code' ); | |
// add plugin functions | |
function thisismyurl_csj_plugin_actions( $links, $file ){ | |
static $this_plugin; | |
if( !$this_plugin ) $this_plugin = plugin_basename( __FILE__ ); | |
if( $file == $this_plugin ){ | |
$settings_link = '<a href="tools.php?page=thisismyurl_csj.php">' . _( 'Settings' ) . '</a>'; | |
$links = array_merge( array( $settings_link ), $links ); // before other links | |
} | |
return $links; | |
} | |
add_filter( 'plugin_action_links', 'thisismyurl_csj_plugin_actions', 10, 2 ); | |
// add scripts to footer | |
add_filter( 'admin_footer', 'thisismyurl_csj_add_scripts', 10, 2 ); | |
// add scripts to header | |
add_filter( 'admin_head', 'thisismyurl_csj_add_scripts_head', 10, 2 ); | |
function thisismyurl_csj_add_scripts( ){ | |
if ( $_GET['page'] == "thisismyurl_csj.php" ) { | |
?> | |
<style> | |
.row {padding: 5px; font-size: .75em;} | |
.odd {background: #efefef;} | |
.even {background: #ffffff;} | |
.key {width: 30%; float: left;} | |
.value {width: 70%; float: left;} | |
</style> | |
<script type='text/javascript' src='/wp-admin/load-scripts.php?c=1&load=hoverIntent,common,jquery-color,wp-ajax-response,wp-lists,jquery-ui-core,jquery-ui-resizable,admin-comments,jquery-ui-sortable,postbox,dashboard,thickbox,plugin-install,media-upload&ver=1c33e12a06a28402104d18bdc95ada53'></script> | |
<?php | |
} | |
} | |
function thisismyurl_csj_add_scripts_head( ){ | |
if ( $_GET['page'] == "thisismyurl_csj.php" ) { | |
?> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
addLoadEvent = function( func ){if( typeof jQuery!="undefined" )jQuery( document ).ready( func );else if( typeof wpOnload!='function' ){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function( ){oldonload( );func( );}}}; | |
var userSettings = { | |
'url': '/', | |
'uid': '2', | |
'time':'1296327223' | |
}, | |
ajaxurl = '/wp-admin/admin-ajax.php', | |
pagenow = 'settings_page_thisismyurl_csj', | |
typenow = '', | |
adminpage = 'settings_page_thisismyurl_csj', | |
thousandsSeparator = ',', | |
decimalPoint = '.', | |
isRtl = 0; | |
//]]> | |
</script> | |
<link rel='stylesheet' href='/wp-admin/load-styles.php?c=1&dir=ltr&load=dashboard,plugin-install,global,wp-admin&ver=030f653716b08ff25b8bfcccabe4bdbd' type='text/css' media='all' /> | |
<script type='text/javascript'> | |
/* <![CDATA[ */ | |
var quicktagsL10n = { | |
quickLinks: "( Quick Links )", | |
wordLookup: "Enter a word to look up:", | |
dictionaryLookup: "Dictionary lookup", | |
lookup: "lookup", | |
closeAllOpenTags: "Close all open tags", | |
closeTags: "close tags", | |
enterURL: "Enter the URL", | |
enterImageURL: "Enter the URL of the image", | |
enterImageDescription: "Enter a description of the image" | |
}; | |
try{convertEntities( quicktagsL10n );}catch( e ){}; | |
/* ]]> */ | |
</script> | |
<script type='text/javascript' src='/wp-admin/load-scripts.php?c=1&load=jquery,utils,quicktags&ver=b50ff5b9792a9e89a2e131ad3119a463'></script> | |
<?php | |
} | |
} | |
function thisismyurl_csj_options( $options='' ) { | |
$options = get_option( 'thisismyurl_csj' ); | |
if ( empty( $options ) ) $options = get_option('cr_csj'); | |
// save page options | |
if ( $_GET['page'] == 'thisismyurl_csj.php' && isset( $_POST['crossslideshowwidth'] ) ) { | |
$options->crossslideshowwidth = $_POST['crossslideshowwidth']; | |
$options->crossslideshowheight = $_POST['crossslideshowheight']; | |
$options->csj_fade = $_POST['csj_fade']; | |
$options->csj_sleep = $_POST['csj_sleep']; | |
$options->csj_kenburns = $_POST['csj_kenburns']; | |
$options->csj_random = $_POST['csj_random']; | |
$options->csj_default_jquery = $_POST['csj_default_jquery']; | |
update_option( 'thisismyurl_csj',$options ); | |
$options = get_option( 'thisismyurl_csj' ); | |
} | |
if ( $_GET['page'] == 'thisismyurl_csj.php' && $_FILES['uploadedfile']['name'] != "" ) { | |
$upload_dir = wp_upload_dir( ); | |
$target_path = $upload_dir['path'].'/'.basename( $_FILES['uploadedfile']['name'] ); | |
$target_url = $upload_dir['url'].'/'. basename( $_FILES['uploadedfile']['name'] ); | |
if( move_uploaded_file( $_FILES['uploadedfile']['tmp_name'], $target_path ) ) { | |
$slideshow = $options->slideshow; | |
$slideshow[] = $target_url; | |
$options->slideshow = $slideshow; | |
update_option( 'thisismyurl_csj',$options ); | |
} else{ | |
_e( 'There was an error uploading the file, please try again!','csj' ); | |
} | |
} | |
// delete slideshow images | |
if ( $_GET['page'] == 'thisismyurl_csj.php' && isset( $_POST['header'] ) ) { | |
$slideshow = $options->slideshow; | |
if ( count( $slideshow ) > 0 ) { | |
foreach ( $slideshow as $header ) { | |
if ( $header != $_POST['header'] ) {$newheader[] = $header;} | |
} | |
} | |
$options->slideshow = $newheader; | |
update_option( 'thisismyurl_csj',$options ); | |
} | |
?> | |
<div class="wrap"> | |
<a href="http://thisismyurl.com/"><div id="cross-icon" style="background: url( '<?php echo WP_PLUGIN_URL .'/'.str_replace( basename( __FILE__ ),"",plugin_basename( __FILE__ ) );?>/icon.png' ) no-repeat;" class="icon32"><br /></div></a> | |
<h2><?php _e( 'Cross Slide for WordPress by Christopher Ross','csj' ) ?></h2> | |
<div class="postbox-container" style="width:70%;"> | |
<div class="metabox-holder"> | |
<div id="normal-sortables" class="meta-box-sortables"> | |
<form action='tools.php?page=thisismyurl_csj.php' method='POST'> | |
<div id="csjsettings" class="postbox"> | |
<div class="handlediv" title="Click to toggle"><br /></div> | |
<h3 class="hndle"><span><?php _e( 'Cross Slide','csj' ) ?></span></h3> | |
<div class="inside"> | |
<p><label><?php _e( 'Width','csj' ) ?>: <input name="crossslideshowwidth" type="text" id="crossslideshowwidth" value="<?php echo $options->crossslideshowwidth; ?>" /></label></p> | |
<p><label><?php _e( 'Height','csj' ) ?>: <input name="crossslideshowheight" type="text" id="crossslideshowheight" value="<?php echo $options->crossslideshowheight; ?>" /></label></p> | |
<p><label><?php _e( 'Sleep','csj' ) ?>: <input name="csj_sleep" type="text" id="csj_sleep" value="<?php echo $options->csj_sleep; ?>" /></label></p> | |
<p><label><?php _e( 'Fade','csj' ) ?>: <input name="csj_fade" type="text" id="csj_fade" value="<?php echo $options->csj_fade; ?>" /></label></p> | |
<p><label><?php _e( 'Default jQuery','csj' ) ?>: <input name="csj_default_jquery" type="checkbox" id="csj_default_jquery" value="1" <?php if ( $options->csj_default_jquery == 1) echo "checked=checked";?> /></label></p> | |
<p><label><?php _e( 'Ken Burns','csj' ) ?>: <input name="csj_kenburns" type="checkbox" value="1" <?php if ( $options->csj_kenburns == '1' ) { echo "checked";}?> /></label></p> | |
<p><label><?php _e( 'Random','csj' ) ?>: <input name="csj_random" type="checkbox" value="1" <?php if ( $options->csj_random == '1' ) { echo "checked";}?> /></label></p> | |
</div> | |
</div> | |
<input style='margin-bottom: 20px;' type="submit" class="button-primary" value="<?php _e( 'Save Changes','csj' ) ?>" /> | |
</form> | |
<div id="csjsettings" class="postbox"> | |
<div class="handlediv" title="Click to toggle"><br /></div> | |
<h3 class="hndle"><span><?php _e( 'Images','csj' ) ?></span></h3> | |
<div class="inside"> | |
<p><?php _e( 'Please add your image files below.','csj' ); ?></p> | |
<?php | |
// loop headers here | |
$slideshow = $options->slideshow; | |
if ( count( $slideshow ) > 0 ) { | |
foreach ( $slideshow as $header ) { | |
echo " <div class='header' style='background-image: url( ".$header." );'> | |
<form action='tools.php?page=thisismyurl_csj.php' method='POST' style='padding: 10px;'> | |
<input type='hidden' id='header' name='header' value='$header'> | |
<input type='submit' class='button' name='remove-feature' value='".__( 'Remove Image' )."' /> | |
</form> | |
</div>"; | |
} | |
} | |
?> | |
<form enctype='multipart/form-data' action='tools.php?page=thisismyurl_csj.php' method='POST'> | |
<input type='hidden' name='MAX_FILE_SIZE' value='500000' /> | |
<input type='file' id='uploadedfile' name='uploadedfile' onchange='headersubmit'/> <input id='headersubmit' name='headersubmit' type="submit" name="Submit" class="button-primary" value="<?php _e( 'Upload','csj' ) ?>" /> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="postbox-container" style="width:20%;"> | |
<div class="metabox-holder"> | |
<div class="meta-box-sortables"> | |
<div id="wordpress-seolike" class="postbox"> | |
<div class="handlediv" title="Click to toggle"><br /></div> | |
<h3 class="hndle"><span><?php _e('Help support this plugin','common');?></span></h3> | |
<div class="inside" style='padding: 0px 10px 5px 10px;'> | |
<p><?php _e('Developing this plugin cost me hours of work. If you like it, please support it. You can help by:','common');?></p> | |
<ul style='padding: 5px 5px 15px 5px; list-style: square; margin-left: 20px;'> | |
<li><a href="http://wordpress.org/extend/plugins/<?php echo $cr_wpname;?>/"><?php _e('Rating it at WordPress.org','common');?></a></li> | |
<li><a href="http://twitter.com/thisismyurl"><?php _e('Following me on Twitter','common');?></a></li> | |
<li><a href="http://www.facebook.com/pages/thisismyurlcom/114745151907899"><?php _e('Becoming a Fan on Facebook','common');?></a></li> | |
</ul> | |
<div style='text-align: center;'> | |
<form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> | |
<input type="hidden" name="cmd" value="_xclick"> | |
<input type="hidden" name="business" value="info@thisismyurl.com"> | |
<input type="hidden" name="item_name" value="Donation for <?php echo $cr_wplink;?>"> | |
<input type="hidden" name="currency_code" value="USD"> | |
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="Make payments with PayPal"> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
<br/><br/><br/> | |
</div> | |
</div> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment