Changeset 537569
- Timestamp:
- 04/28/2012 03:02:01 AM (14 years ago)
- Location:
- ribbon-maker/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (5 diffs)
-
ribbon-maker.php (modified) (5 diffs)
-
screenshot-1.png (modified) (previous)
-
screenshot-3.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
ribbon-maker/trunk/readme.txt
r536377 r537569 5 5 Requires at Least: 3.0.0 6 6 Tested Up To: 3.3.2 7 Stable tag: 1. 117 Stable tag: 1.2 8 8 9 9 Make your own ribbon now without waiting for a plugin designer to do it for you. … … 11 11 == Description == 12 12 13 A ribbon creation plugin that will allow you to generate your own ribbons in real time . They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.13 A ribbon creation plugin that will allow you to generate your own ribbons in real time for up to 4 corners. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text. 14 14 15 15 == Installation == … … 20 20 21 21 == Screenshots == 22 1. Preview Section of configuration 23 2. The configuration page options 24 3. An example of th e ribbonon your site.22 1. Preview Section of configuration with 4 ribbons displayed. 23 2. The configuration page options. 24 3. An example of three of the ribbons on your site. 25 25 26 26 == Changelog == 27 = 1.2 = 28 Added the other 3 corners. 29 27 30 = 1.11 = 28 31 Ok, I'm going to make a checklist of stuff that must be double checked before I commit. This is like the 3rd time I've done this on accident. Get all committed and discover that something minor but crucial got left out. Grrrr. … … 56 59 57 60 == Upgrade Notice == 61 = 1.2 = 62 Now you aren't limited to the one corner, get up to all 4 at once if you like! Also, your database is automatically updated in regards to the ribbon you've made now, but you will have to save again to make it convert over. 63 58 64 = 1.11 = 59 65 Not a critical update -- see changelog … … 71 77 This plugin requires the GD image library in your PHP 5.x installation to be enabled and fully operational. 72 78 == TODO == 73 1. Switch to a comletely CSS driven routine. Which will solve resolution issues and transparency issues. Because the GD library sucks. For some reason GD is forcing me to use the "black" color for the transparency. It is not agreeing with the code at PHP.net. Going CSS will solve this issue. I just have to wrap my mind around CSS now. :D 74 2. Give you more control of how the ribbon graphic looks. 75 4. Fix transparency issue. 76 5. Allow you to create multiple ribbons. 77 6. Allow you to have multiple ribbons on a page. 78 7. Allow ribbons to be scheduled. 79 = Allow Custom Images = 80 Decided that allowing you to add a custom image in place of an autogenerated one should be an option. This likely will be in the next release. 81 = CSS Functionality = 82 Switch to a comletely CSS driven routine. Which will solve resolution issues and transparency issues. Because the GD library sucks. For some reason GD is forcing me to use the "black" color for the transparency. It is not agreeing with the code at PHP.net. Going CSS will solve this issue. I just have to wrap my mind around CSS now. :D 83 = Design Choices = 84 Give you more control of how the ribbon graphic looks. 85 = Transparency = 86 Fix transparency issue. I checked with browsershots.org and it seems the images are drawing great. So if I can solve the issue where GD insists on black being the only transparent color for the background, things will be better. 87 = Decorative Types = 88 Give ability to create other types of shapes and patterns. 89 = Scheduling = 90 Allow the decorations to be scheduled to appear on any given time and day. This is great for the holidays, special events and more! -
ribbon-maker/trunk/ribbon-maker.php
r536377 r537569 5 5 Description: When activated, this plugin will put a ribbon of your design, message and custom link on the top right corner of your website. 6 6 Author: Al Lamb 7 Version: 1. 117 Version: 1.2 8 8 License: GPLv2 9 9 Author URI: http://bowierocks.com … … 11 11 12 12 function ribbon_maker_getVersion() { 13 return "1.11";13 return "1.2"; 14 14 } 15 15 16 16 function ribbon_maker_getDownload() { 17 return "http://wordpress.org/extend/plugins/ribbon-maker";17 return "http://wordpress.org/extend/plugins/ribbon-maker"; 18 18 } 19 19 … … 23 23 24 24 function ribbon_maker_isChecked($test,$string) { 25 if($test==$string) return "checked"; 26 return ""; 25 if($test==$string) return "checked"; 26 return ""; 27 } 28 29 function ribbon_maker_was_it_saved($test) { 30 if ( $test ) 31 echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>'); 32 else 33 echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>'); 34 } 35 36 function ribbon_maker_convert_db($new,$old) { 37 //$old is both the name of the old variable and the old value that needs to come forward 38 $result = update_option($new,get_option($old)); 39 delete_option($old); 40 return $result; 27 41 } 28 42 … … 32 46 <h2>Ribbon Maker Options</h2><address style="font-size: 8pt; font-weight: 700;">'.ribbon_maker_getVersion().' (<a href="'.ribbon_maker_getDownload().'" target="_blank">Ribbon Maker</a>)</address> 33 47 '); 34 if ( isset( $_POST['submit'] ) ) { 35 $str = strtr( $_POST['ribbon_maker_url'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 36 $ribbon_maker = update_option( 'ribbon_maker_url', $str ); 37 $str = strtr( $_POST['ribbon_maker_title'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 38 $ribbon_maker .= update_option( 'ribbon_maker_title', $str); 39 $str = strtr( $_POST['ribbon_maker_admin_offset'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 40 $ribbon_maker .= update_option( 'ribbon_maker_admin_offset', $str ); 41 $str = strtr( $_POST['ribbon_maker_user_offset'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 42 $ribbon_maker .= update_option( 'ribbon_maker_user_offset', $str ); 48 if (get_option('ribbon_maker_url')) { //convert the database entries 49 50 $ribbon_maker = ribbon_maker_convert_db( 'ribbon_maker_url1', 'ribbon_maker_url' ); 51 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_title1', 'ribbon_maker_title'); 52 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_admin_offset1', 'ribbon_maker_admin_offset' ); 53 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_user_offset1', 'ribbon_maker_user_offset' ); 54 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_message1', 'ribbon_maker_message' ); 55 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_bgcolor1', 'ribbon_maker_bgcolor' ); 56 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_fgcolor1', 'ribbon_maker_fgcolor' ); 57 $ribbon_maker .= ribbon_maker_convert_db( 'ribbon_maker_active1', 'ribbon_maker_active' ); 58 59 ribbon_maker_was_it_saved($ribbon_maker); 60 } 61 62 if ( isset( $_POST['submit'] ) && !isset($_POST['not_saving']) ) { 63 $str = strtr( $_POST['ribbon_maker_url'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 64 $ribbon_maker = update_option( 'ribbon_maker_url'.$_POST['ribbon_maker_slot'], $str ); 65 $str = strtr( $_POST['ribbon_maker_title'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 66 $ribbon_maker .= update_option( 'ribbon_maker_title'.$_POST['ribbon_maker_slot'], $str); 67 $str = strtr( $_POST['ribbon_maker_admin_offset'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 68 $ribbon_maker .= update_option( 'ribbon_maker_admin_offset'.$_POST['ribbon_maker_slot'], $str ); 69 $str = strtr( $_POST['ribbon_maker_user_offset'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 70 $ribbon_maker .= update_option( 'ribbon_maker_user_offset'.$_POST['ribbon_maker_slot'], $str ); 43 71 //$str = strtr( $_POST['ribbon_maker_message'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 44 $ribbon_maker .= update_option( 'ribbon_maker_message', $_POST['ribbon_maker_message'] ); 45 $str = strtr( $_POST['ribbon_maker_bgcolor'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 46 $ribbon_maker .= update_option( 'ribbon_maker_bgcolor', $str ); 47 $str = strtr( $_POST['ribbon_maker_fgcolor'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 48 $ribbon_maker .= update_option( 'ribbon_maker_fgcolor', $str ); 49 $str = strtr( $_POST['ribbon_maker_active'], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 50 $ribbon_maker .= update_option( 'ribbon_maker_active', $str ); 51 if ( $ribbon_maker ) 52 echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>'); 53 else 54 echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>'); 55 } 56 57 ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor')); 58 59 echo "<hr>Ribbon Preview: <img valign='top' src='".plugins_url("ribbon_maker_ribbon.png",__FILE__)."'><br>"; 72 $ribbon_maker .= update_option( 'ribbon_maker_message'.$_POST['ribbon_maker_slot'], $_POST['ribbon_maker_message'.$_POST['ribbon_maker_slot']] ); 73 $str = strtr( $_POST['ribbon_maker_bgcolor'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 74 $ribbon_maker .= update_option( 'ribbon_maker_bgcolor'.$_POST['ribbon_maker_slot'], $str ); 75 $str = strtr( $_POST['ribbon_maker_fgcolor'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 76 $ribbon_maker .= update_option( 'ribbon_maker_fgcolor'.$_POST['ribbon_maker_slot'], $str ); 77 $str = strtr( $_POST['ribbon_maker_active'.$_POST['ribbon_maker_slot']], array( '"' => '"', '\\' => '', '\'' => ''' ) ); 78 $ribbon_maker .= update_option( 'ribbon_maker_active'.$_POST['ribbon_maker_slot'], $str ); 79 //ribbon_maker_slot is transient so we don't save it 80 ribbon_maker_was_it_saved ( $ribbon_maker ); 81 } 82 //display the 4 corner shots 83 echo ("<table><tr><th colspan=4 align='center'>Ribbon Preview</th><tr><th>Upper Right</th><th>Lower Right</th><th>Lower Left</th><th>Upper Left</th></tr>"); 84 echo("<tr>"); 85 for($i=1;$i<=4;$i++) { 86 echo ("<td>"); 87 88 ribbon_maker_create_ribbon($i); 89 echo "<img valign='top' width='150' align='center' src='".plugins_url("ribbon_maker_ribbon$i.png",__FILE__)."'><br>"; 90 echo "</td>"; 91 } 92 echo "</tr>"; 93 echo "<tr>"; 94 for($i=1;$i<=4;$i++) { 95 echo "<td align='center'><form action='' method='post'><input type='hidden' name='not_saving' value='1'><input type='hidden' name='ribbon_maker_slot' value='$i'><input type='submit' value='Edit Ribbon $i'></form>"; 96 echo ("</td>"); 97 } 98 echo ("</tr></table>"); 99 100 switch($_POST['ribbon_maker_slot']) { 101 case 1: 102 $announce = "upper right"; 103 $slot = 1; 104 break; 105 case 2: 106 $announce = "lower right"; 107 $slot = 2; 108 break; 109 case 3: 110 $announce = "lower left"; 111 $slot = 3; 112 break; 113 case 4: 114 $announce = "upper left"; 115 $slot = 4; 116 break; 117 default: 118 $announce = "upper right"; 119 $slot = 1; //default 120 break; 121 } 60 122 123 echo ("<ht><b><h3>Now editing the $announce corner.</h3></b><br>"); 61 124 echo(' 62 125 <form action="" method="post"> 63 126 <table class="form-table"> 64 127 <tr><td>URL to Link to<br/><span class="ribbon_maker_hint">Insert full HTTP quallifed link. for example: http://bowierocks.com/donate</span></td> 65 <td><input type="text" name="ribbon_maker_url" size="80" value="'.get_option( 'ribbon_maker_url','http://bowierocks.com/ribbon-maker' ).'"></td> 66 </tr> 128 <td> 129 <input type="hidden" name="ribbon_maker_slot" value="'.$_POST['ribbon_maker_slot'].'"><input type="text" name="ribbon_maker_url'.$slot.'" size="80" value="'.get_option( "ribbon_maker_url$slot",'http://bowierocks.com/ribbon-maker' ).'"></td> 130 </tr> 67 131 <tr><td>TITLE for Link<br/><span class="ribbon_maker_hint">This is the message that pops up when you hove over links.</span></td> 68 <td><input type="text" name="ribbon_maker_title" size="80" value="'.get_option( 'ribbon_maker_title','Get Support at BowieRocks.com for Ribbon Maker' ).'"></td>69 </tr>132 <td><input type="text" name="ribbon_maker_title'.$slot.'" size="80" value="'.get_option( "ribbon_maker_title$slot",'Get Support at BowieRocks.com for Ribbon Maker' ).'"></td> 133 </tr> 70 134 <tr><td>MESSAGE for Ribbon<br/><span class="ribbon_maker_hint">This is the message that pops up when you hove over links.</span></td> 71 <td><input type="text" name="ribbon_maker_message" size="80" value="'.stripslashes(get_option( 'ribbon_maker_message', 'Ribbon Maker by Al Lamb' )).'"></td> 72 </tr> 73 74 <tr><td>BGCOLOR of Ribbon<br/><span class="ribbon_maker_hint">This is the color of the objects that make up the ribbon.</span></td> 75 <td><input type="text" name="ribbon_maker_bgcolor" size="10" maxlength=7 value="'.get_option( 'ribbon_maker_bgcolor','000000' ).'"></td> 76 </tr> 135 <td><input type="text" name="ribbon_maker_message'.$slot.'" size="80" value="'.stripslashes(get_option( "ribbon_maker_message$slot", 'Ribbon Maker by Al Lamb' )).'"></td> 136 </tr> 137 <tr><td>BGCOLOR of Ribbon<br/><span class="ribbon_maker_hint">This is the color of the objects that make up the ribbon.</span></td> 138 <td><input type="text" name="ribbon_maker_bgcolor'.$slot.'" size="10" maxlength=7 value="'.get_option( "ribbon_maker_bgcolor$slot",'000000' ).'"></td> 139 </tr> 77 140 <tr><td>FGCOLOR of Ribbon<br/><span class="ribbon_maker_hint">This is the color of the text comprising the message.</span></td> 78 <td><input type="text" name="ribbon_maker_fgcolor" size="10" maxlength=7 value="'.get_option( 'ribbon_maker_fgcolor','ffffff' ).'"></td>79 </tr>141 <td><input type="text" name="ribbon_maker_fgcolor'.$slot.'" size="10" maxlength=7 value="'.get_option( "ribbon_maker_fgcolor$slot",'ffffff' ).'"></td> 142 </tr> 80 143 <tr><td>Admin Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the ADMIN bar.</span></td> 81 <td><input type="text" name="ribbon_maker_admin_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_admin_offset','0' ).'"></td>82 </tr>144 <td><input type="text" name="ribbon_maker_admin_offset'.$slot.'" size="5" maxlength=5 value="'.get_option( "ribbon_maker_admin_offset$slot",'0' ).'"></td> 145 </tr> 83 146 <tr><td>User Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the USER bar.</span></td> 84 <td><input type="text" name="ribbon_maker_user_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_user_offset','0' ).'"></td>85 </tr>147 <td><input type="text" name="ribbon_maker_user_offset'.$slot.'" size="5" maxlength=5 value="'.get_option( "ribbon_maker_user_offset$slot",'0' ).'"></td> 148 </tr> 86 149 <tr><td>Make Ribbon Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will be visible on your blog.</span></td> 87 <td><input type="radio" name="ribbon_maker_active" value="active" '.ribbon_maker_isChecked('active',get_option('ribbon_maker_active')).'></td>88 </tr>150 <td><input type="radio" name="ribbon_maker_active'.$slot.'" value="active" '.ribbon_maker_isChecked('active',get_option("ribbon_maker_active$slot")).'></td> 151 </tr> 89 152 <tr><td>Make Ribbon In-Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will NOT be visible on your blog.</span></td> 90 <td><input type="radio" name="ribbon_maker_active" value="inactive" '.ribbon_maker_isChecked('inactive',get_option('ribbon_maker_active')).'></td>91 </tr>153 <td><input type="radio" name="ribbon_maker_active'.$slot.'" value="inactive" '.ribbon_maker_isChecked('inactive',get_option("ribbon_maker_active$slot")).'></td> 154 </tr> 92 155 <hr /> 93 156 <tr><td colspan="2"><hr /></td></tr> … … 114 177 115 178 function ribbon_maker_get_color($sample,$color) { 116 switch($color) { 117 case "red": 118 $sample = substr($sample,0,2); 119 break; 120 case "green": 121 $sample = substr($sample,2,2); 122 break; 123 case "blue": 124 $sample = substr($sample,4,2); 125 break; 126 default: 127 $sample = "00"; //should never get this! but just in case 128 } 129 return hexdec($sample); 130 } 131 132 function ribbon_maker_create_ribbon($string,$bgcolor,$fgcolor) { 133 $font = 5; 134 $width = ImageFontWidth($font) * strlen($string)+ImageFontWidth($font)*4; 135 $height = ImageFontHeight($font)+8; 136 $im = imagecreatetruecolor ($width,$height); 137 138 $back = imagecolorallocate($im, 0,0,0); 139 $draw_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($bgcolor,"red"), (int)ribbon_maker_get_color($bgcolor,"green"), (int)ribbon_maker_get_color($bgcolor,"blue")); 140 $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue")); 141 142 //imagefill($im,0,0,$back); 143 144 imageline($im, 0,2,$width,2,$draw_color); 145 imageline($im, 0,3,$width,3,$draw_color); 146 147 imagefilledrectangle($im,0,5,$width,$height-5,$draw_color); 148 149 imageline($im, 0,$height-3,$width,$height-3,$draw_color); 150 imageline($im, 0,$height-2,$width,$height-2,$draw_color); 151 152 imagestring ($im, $font, ImageFontWidth($font)*2, 4, stripslashes($string), $text_color); 153 154 $new_img = imagerotate ($im, 360-45, 0); 155 156 //now we shall try and crop the image, increase its dpi and thus make the ribbon flush 157 //all in one go 158 imagedestroy ($im); 159 $newWidth=imagesx($new_img)-ImageFontWidth($font); 160 $newHeight=imagesy($new_img)-ImageFontHeight($font); 161 $im = imagecreatetruecolor($newWidth,$newHeight); 162 163 /* 164 bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 165 */ 166 imagecopyresampled($im,$new_img,0,0,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font)); 167 168 imagecolortransparent($im,$back); 169 170 //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image! 171 imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image! 172 imagedestroy ($new_img); 173 imagedestroy ($im); 179 switch($color) { 180 case "red": 181 $sample = substr($sample,0,2); 182 break; 183 case "green": 184 $sample = substr($sample,2,2); 185 break; 186 case "blue": 187 $sample = substr($sample,4,2); 188 break; 189 default: 190 $sample = "00"; //should never get this! but just in case 191 } 192 return hexdec($sample); 193 } 194 195 function ribbon_maker_create_ribbon($slot) { 196 $string = get_option('ribbon_maker_message'.$slot); 197 $bgcolor = get_option('ribbon_maker_bgcolor'.$slot); 198 $fgcolor = get_option('ribbon_maker_fgcolor'.$slot); 199 $font = 5; 200 $width = ImageFontWidth($font) * strlen($string)+ImageFontWidth($font)*8; 201 $height = ImageFontHeight($font)+8; 202 $im = imagecreatetruecolor ($width,$height); 203 204 $back = imagecolorallocate($im, 0,0,0); 205 $draw_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($bgcolor,"red"), (int)ribbon_maker_get_color($bgcolor,"green"), (int)ribbon_maker_get_color($bgcolor,"blue")); 206 $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue")); 207 208 //imagefill($im,0,0,$back); 209 210 imageline($im, 0,2,$width,2,$draw_color); 211 imageline($im, 0,3,$width,3,$draw_color); 212 213 imagefilledrectangle($im,0,5,$width,$height-5,$draw_color); 214 215 imageline($im, 0,$height-3,$width,$height-3,$draw_color); 216 imageline($im, 0,$height-2,$width,$height-2,$draw_color); 217 218 imagestring ($im, $font, $width/2-(strlen($string)*ImageFontWidth($font))/2, 4, stripslashes($string), $text_color); 219 $rotation = (-90*($slot-1))+45; 220 switch($slot) { 221 case 1: 222 $rotation = 45; 223 break; 224 case 2: 225 $rotation = -45; 226 break; 227 case 3: 228 $rotation = 45; 229 break; 230 case 4: 231 $rotation = -45; 232 break; 233 } 234 $new_img = imagerotate ($im, 360-$rotation, 0); 235 236 //now we shall try and crop the image and thus make the ribbon flush 237 //all in one go 238 imagedestroy ($im); 239 $newWidth=imagesx($new_img)-ImageFontWidth($font); 240 $newHeight=imagesy($new_img)-ImageFontHeight($font); 241 $im = imagecreatetruecolor($newWidth,$newHeight); 242 243 /* 244 bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) 245 */ 246 $dst_x=0; 247 $dst_y=0; 248 $dst_w=imagesx($im); 249 $dst_h=imagesy($im); 250 switch($slot) { 251 case 1: 252 imagecopyresampled($im,$new_img,$dst_x,$dst_y,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font)); 253 break; 254 case 2: 255 imagecopyresampled($im,$new_img,$dst_x,$dst_y,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*3.3,imagesy($new_img)-ImageFontHeight($font)*2.7); 256 break; 257 case 3: 258 imagecopyresampled($im,$new_img,$dst_x,$dst_y,ImageFontWidth($font)*2.7,0,$newWidth,$newHeight,imagesx($new_img),imagesy($new_img)-ImageFontHeight($font)*1.8); 259 break; 260 case 4: 261 imagecopyresampled($im,$new_img,$dst_x,$dst_y,ImageFontWidth($font)*2.7,ImageFontHeight($font)*1.8,$newWidth,$newHeight,imagesx($new_img),imagesy($new_img)); 262 break; 263 } 264 265 imagecolortransparent($im,$back); 266 267 //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image! 268 imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon$slot.png");//this actually writes out the image! 269 imagedestroy ($new_img); 270 imagedestroy ($im); 174 271 } 175 272 176 273 function render_ribbon_maker() { 177 if(get_option("ribbon_maker_active")=="active") { 178 if(is_admin_bar_showing()) 179 $offset = get_option("ribbon_maker_admin_offset"); 180 else 181 $offset = get_option("ribbon_maker_user_offset"); 182 183 $img = plugins_url('ribbon_maker_ribbon.png',__FILE__); 184 185 echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>"; 186 } 274 for ($i=1;$i<=4;$i++) 275 if(get_option("ribbon_maker_active$i")=="active") { 276 if(is_admin_bar_showing()) 277 $offset = get_option("ribbon_maker_admin_offset$i"); 278 else 279 $offset = get_option("ribbon_maker_user_offset$i"); 280 281 $img = plugins_url("ribbon_maker_ribbon$i.png",__FILE__); 282 283 switch($i) { 284 case 1: 285 $tob="top"; 286 $lor="right"; 287 break; 288 case 2: 289 $tob="bottom"; 290 $lor="right"; 291 break; 292 case 3: 293 $tob="bottom"; 294 $lor="left"; 295 break; 296 default: //ie is this really case 4 297 $tob="top"; 298 $lor="left"; 299 break; 300 } 301 echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url$i")."' title='".get_option("ribbon_maker_title$i")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; $tob: {$offset}px; $lor: 0; z-index: 100000; cursor: pointer;' /></a>"; 302 } 187 303 } 188 304
Note: See TracChangeset
for help on using the changeset viewer.